diff --git a/Makefile b/Makefile index 71861def..358b9953 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION=1.1 CONFIG=Debug -LDYDESTDIR=build/web/$(CONFIG) +LDYDESTDIR=dist/web/$(CONFIG) COPYUNCHANGED="false" RSYNCCMD=rsync -ravu --chown=www-data:www-data HOST_rsync_dev=totemdev.localdomain @@ -28,7 +28,7 @@ rsync_% : DESTDIR = $(DESTDIR_$@) rsync_% : deploy echo "!Deploying to $(HOST)!" - $(RSYNCCMD) build/web/$(CONFIG)/ root@$(HOST):$(DESTDIR) + $(RSYNCCMD) dist/web/$(CONFIG)/ root@$(HOST):$(DESTDIR) ssh root@$(HOST) "service apache2 reload" build: diff --git a/NpgsqlBlogProvider/ChangeLog b/NpgsqlBlogProvider/ChangeLog deleted file mode 100644 index bbbab81c..00000000 --- a/NpgsqlBlogProvider/ChangeLog +++ /dev/null @@ -1,14 +0,0 @@ -2015-10-09 Paul Schneider - - * NpgsqlBlogProvider.cs: - Fixes access on bills - - Fixes usage of bill without photo - -2015-10-08 Paul Schneider - - * NpgsqlBlogProvider.cs: Fixes last commit in case of DBNull - reading the photo - -2015-10-08 Paul Schneider - - * NpgsqlBlogProvider.cs: implements a blog post photo storage - diff --git a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs index c623f560..d72cd624 100644 --- a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs +++ b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs @@ -434,7 +434,7 @@ namespace Npgsql.Web.Blog if (circles.Length>0) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "insert into blog_access (post_id,circle_id) values (:pid,:cid)"; - cmd.Parameters.AddWithValue ("pid", pid); + cmd.Parameters.AddWithValue ("pid", NpgsqlTypes.NpgsqlDbType.Bigint, pid); cmd.Parameters.Add ("cid", NpgsqlTypes.NpgsqlDbType.Bigint); cmd.Prepare (); foreach (long ci in circles) { diff --git a/TestAPI/BlogUnitTest.cs b/TestAPI/BlogUnitTest.cs new file mode 100644 index 00000000..be591a08 --- /dev/null +++ b/TestAPI/BlogUnitTest.cs @@ -0,0 +1,76 @@ +// +// BlogUnitTest.cs +// +// Author: +// Paul Schneider +// +// Copyright (c) 2015 GNU GPL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +using NUnit.Framework; +using System; +using Yavsc.Model.Blogs; +using Yavsc.Controllers; +using System.Web.Mvc; +using System.Web.Security; + +namespace TestAPI +{ + [TestFixture ()] + public class BlogUnitTest + { + + public string UserName { get; set; } + public string Email { get; set; } + public string Password { get; set; } + + + AccountController accountController; + [TestFixtureSetUp] + public void Init() + { + accountController = new AccountController (); + } + + [Test ()] + public void Register () + { + ViewResult actionResult = accountController.Register ( + new Yavsc.Model.RolesAndMembers.RegisterViewModel () { + UserName = UserName, Email = Email, + Password = "tpwd", ConfirmPassword = Password, + IsApprouved = true + }, + "/testreturnurl") as ViewResult; + Assert.AreEqual (actionResult.ViewName, "RegistrationPending"); + MembershipUser u = Membership.GetUser (UserName, false); + Assert.NotNull (u); + Assert.False (u.IsApproved); + // TODO : check mail for test, + // get the validation key from its body, + // and use the accountController.Validate(username,key) + u.IsApproved = true; + Membership.UpdateUser (u); + Assert.True (u.IsApproved); + } + [TestFixtureTearDown()] + public void Unregister() + { + ViewResult actionResult = + accountController.Unregister (UserName, true) as ViewResult; + Assert.AreEqual (actionResult.ViewName, "Index"); + } + } +} + diff --git a/TestAPI/TestAPI.csproj b/TestAPI/TestAPI.csproj index ed962888..8e601b4c 100644 --- a/TestAPI/TestAPI.csproj +++ b/TestAPI/TestAPI.csproj @@ -9,7 +9,7 @@ Library TestAPI TestAPI - v4.5 + v4.5.1 true @@ -55,10 +55,14 @@ ..\packages\Spark.1.8.1.0\lib\NET45\Spark.dll + + + + @@ -66,6 +70,10 @@ {68F5B80A-616E-4C3C-91A0-828AA40000BD} YavscModel + + {77044C92-D2F1-45BD-80DD-AA25B311B027} + Web + diff --git a/web/Admin/DataManager.cs b/web/Admin/DataManager.cs index fb994200..33b8a71d 100644 --- a/web/Admin/DataManager.cs +++ b/web/Admin/DataManager.cs @@ -40,7 +40,7 @@ namespace Yavsc.Admin */ Exec ("pg_dump", string.Format ( "-f {0} -Ft -h {1} -U {2} -p {3} {4}", - fileName, da.Host, da.Dbuser, da.Port, da.Dbname ),e); + fileName, da.Host, da.DbUser, da.Port, da.DbName ),e); return e; } @@ -74,7 +74,7 @@ namespace Yavsc.Admin var t = new TaskOutput (); Exec ("pg_restore", (dataOnly?"-a ":"")+string.Format ( "-1 -Ft -O -h {0} -U {1} -p {2} -d {3} {4}", - da.Host, da.Dbuser, da.Port, da.Dbname, fileName ),t); + da.Host, da.DbUser, da.Port, da.DbName, fileName ),t); /* Exec ("pg_restore", (dataOnly?"-a ":"")+string.Format ( "-1 -w -Fd -O -h {0} -U {1} -p {2} -d {3} {4}", @@ -149,7 +149,7 @@ namespace Yavsc.Admin var t = new TaskOutput (); Exec ("pg_restore", string.Format ( "-a -w -Fd -O -h {0} -U {1} -p {2} -d {3} {4}", - da.Host, da.Dbuser, da.Port, da.Dbname, fileName ),t); + da.Host, da.DbUser, da.Port, da.DbName, fileName ),t); return t; } } diff --git a/web/Admin/Export.cs b/web/Admin/Export.cs index 6b3256de..e2120f43 100644 --- a/web/Admin/Export.cs +++ b/web/Admin/Export.cs @@ -1,7 +1,7 @@ using System; using System.ComponentModel; -namespace Yavsc.Admin +namespace Yavsc.Model.Admin { /// /// Export. @@ -9,7 +9,7 @@ namespace Yavsc.Admin public class Export: TaskOutput { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public Export () { diff --git a/web/ApiControllers/AccountController.cs b/web/ApiControllers/AccountController.cs index 6c45c52c..1a7e2362 100644 --- a/web/ApiControllers/AccountController.cs +++ b/web/ApiControllers/AccountController.cs @@ -72,7 +72,7 @@ namespace Yavsc.ApiControllers break; case MembershipCreateStatus.Success: if (!model.IsApprouved) - YavscHelpers.SendActivationMessage (user); + Url.SendActivationMessage (user); ProfileBase prtu = ProfileBase.Create (model.UserName); prtu.SetPropertyValue("Name",model.Name); prtu.SetPropertyValue("Address",model.Address); @@ -99,9 +99,12 @@ namespace Yavsc.ApiControllers public void ResetPassword(LostPasswordModel model) { StringDictionary errors; - YavscHelpers.ResetPassword (model, out errors); + MembershipUser user; + YavscHelpers.ValidatePasswordReset (model, out errors, out user); foreach (string key in errors.Keys) ModelState.AddModelError (key, errors [key]); + if (user != null && ModelState.IsValid) + Url.SendActivationMessage (user); } } } diff --git a/web/ApiControllers/BlogsController.cs b/web/ApiControllers/BlogsController.cs index 67ad442f..a06052a2 100644 --- a/web/ApiControllers/BlogsController.cs +++ b/web/ApiControllers/BlogsController.cs @@ -165,7 +165,7 @@ namespace Yavsc.ApiControllers try { // Read the form data. - await Request.Content.ReadAsMultipartAsync(provider) ; + IEnumerable data = await Request.Content.ReadAsMultipartAsync(provider) ; var invalidChars = Path.GetInvalidFileNameChars(); List bodies = new List(); @@ -173,10 +173,8 @@ namespace Yavsc.ApiControllers foreach (string fkey in provider.BodyPartFileNames.Keys) { string filename = provider.BodyPartFileNames[fkey]; - + string nicename=fkey; - if (fkey.StartsWith("\"") && fkey.EndsWith("\"") && fkey.Length > 2) - nicename = fkey.Substring(1,fkey.Length-2); var filtered = new string (nicename.Where( x=> !invalidChars.Contains(x)).ToArray()); FileInfo fi = new FileInfo(filtered); @@ -184,6 +182,10 @@ namespace Yavsc.ApiControllers FileInfo fp = new FileInfo (Path.Combine(root,filename)); if (fi.Exists) fi.Delete(); fp.MoveTo(fi.FullName); + // Get the mime type + + + using (Process p = new Process ()) { p.StartInfo.WorkingDirectory = root; p.StartInfo = new ProcessStartInfo (); @@ -206,14 +208,14 @@ namespace Yavsc.ApiControllers ); } } - bodies.Add(fo.OpenText().ReadToEnd()); + parts.Add(fo.OpenText().ReadToEnd()); fi.Delete(); fo.Delete(); } - return Request.CreateResponse(HttpStatusCode.OK,string.Join("---\n",bodies),new SimpleFormatter("text/plain")); + return Request.CreateResponse(HttpStatusCode.OK,string.Join("---\n",parts),new SimpleFormatter("text/plain")); } catch (System.Exception e) diff --git a/web/ApiControllers/CalendarController.cs b/web/ApiControllers/CalendarController.cs index 9919ff1b..d1b8300f 100644 --- a/web/ApiControllers/CalendarController.cs +++ b/web/ApiControllers/CalendarController.cs @@ -27,6 +27,7 @@ using Yavsc.Helpers; using System.Web.Profile; using Yavsc.Model.Circles; using Yavsc.Model.Calendar; +using System.Web.Http.Routing; namespace Yavsc.ApiControllers @@ -160,7 +161,7 @@ namespace Yavsc.ApiControllers "déjà enregistré"); break; case MembershipCreateStatus.Success: - YavscHelpers.SendActivationMessage (user); + Url.SendActivationMessage (user); // TODO set registration id throw new NotImplementedException (); } diff --git a/web/ApiControllers/WorkFlowController.cs b/web/ApiControllers/WorkFlowController.cs index 8a79f680..ca0cf435 100644 --- a/web/ApiControllers/WorkFlowController.cs +++ b/web/ApiControllers/WorkFlowController.cs @@ -85,7 +85,8 @@ namespace Yavsc.ApiControllers return ; case MembershipCreateStatus.Success: if (!userModel.IsApprouved) - YavscHelpers.SendActivationMessage (user); + + Url.SendActivationMessage (user); return; default: throw new InvalidOperationException (string.Format("Unexpected user creation code :{0}",mcs)); diff --git a/web/App_Themes/style.css b/web/App_Themes/style.css index 6f712f96..c3de49d2 100644 --- a/web/App_Themes/style.css +++ b/web/App_Themes/style.css @@ -273,6 +273,14 @@ input, select { font-size: smaller; } + +.menuitem { + border-radius:5px; + margin:.5em; + padding:.5em; + display: inline-block; +} + .onhover { display:none; position: absolute; @@ -295,12 +303,10 @@ input, select { .control,.actionlink,nav { display:none;} } -@media all and (min-width: 640px) { .bshpanel { display:block; } .bsh { display: none; } .c3 { display:initial; } .c3-alt { display:none; } - } @media all and (max-width: 640px) { nav { diff --git a/web/ChangeLog b/web/ChangeLog deleted file mode 100644 index f4ae7dba..00000000 --- a/web/ChangeLog +++ /dev/null @@ -1,88 +0,0 @@ -2015-10-09 Paul Schneider - - * totem-banner.png: - * totem-banner.xs.jpg: - * totem-banner.xxs.jpg: totem custo - - * style.css: yastyle - - * AccountController.cs: - Fixes route usage with n ovalue for - `id` - - better code at getting the avatar url - - - * BlogsController.cs: Fixes a Post request without user name - in the route - - * YavscHelpers.cs: Implements a file list html rendering - - * App.master: - * UserPost.aspx: - * Profile.aspx: - * AssemblyInfo.aspx: yahtmlstructure - - * Edit.aspx: Displays a list a attached files - - * UserPosts.aspx: yahtmlstrucure - - * Web.csproj: new images - - * instdbws.sql: returns to the flat list of properies (groups - are not working) - -2015-10-08 Paul Schneider - - * Contact.aspx: a form background color - - * Index.aspx: A link to the credits page - - * HomeController.cs: A Credits page - - * Credits.aspx: A page title and H1 links - - * AssemblyInfo.aspx: A relevant title - -2015-10-08 Paul Schneider - - * style.css: yastyle - -2015-10-08 Paul Schneider - - * BlogsController.cs: implements a method to update the photo - url - - * style.css: yastyle - - * AdminController.cs: refactoring the notification: - Introduces a static `Notice` method, server side, to populate - an array - in `ViewData`, used in the paster page. - - * BlogsController.cs: Controls the photo update - - * YavscHelpers.cs: - * yavsc.circles.js: - * HomeController.cs: - * GoogleController.cs: notification refactoring - - * App.master: - notification refactoring - - html structure in the `nav` - - * hallo.js: event 'hallomodified' now also occurs at image - modifications - - * to-markdown.js: ?Fixes? html images alt text and title to - Markdown - - * yavsc.js: implements the photo in database - - * Edit.aspx: A nicer bill edition, with a photo - - * UserPost.aspx: Displays the photo - - * UserPosts.aspx: Fixes the new usage of `ResultPages` - - * Web.config: totem custo - - * instdbws.sql: adds a `photo` field in the `blog` table - diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs index 5b43c8c4..43804f3b 100644 --- a/web/Controllers/AccountController.cs +++ b/web/Controllers/AccountController.cs @@ -24,7 +24,7 @@ namespace Yavsc.Controllers /// public class AccountController : Controller { - + string avatarDir = "~/avatars"; string defaultAvatar; string defaultAvatarMimetype; @@ -37,20 +37,7 @@ namespace Yavsc.Controllers [AcceptVerbs (HttpVerbs.Get)] public ActionResult Avatar (string id) { - if (id == null) - return new EmptyResult (); - - ProfileBase pr = ProfileBase.Create (id); - var avpath = pr.GetPropertyValue("Avatar"); - if (avpath == null) { - FileInfo fia = new FileInfo (Server.MapPath (defaultAvatar)); - return File (fia.OpenRead (), defaultAvatarMimetype); - } - string avatarLocation = avpath as string; - if (avatarLocation.StartsWith ("~/")) { - avatarLocation = Server.MapPath (avatarLocation); - } - + string avatarLocation = Url.AvatarUrl (id); WebRequest wr = WebRequest.Create (avatarLocation); FileContentResult res; using (WebResponse resp = wr.GetResponse ()) { @@ -130,11 +117,17 @@ namespace Yavsc.Controllers return View (); } + public ActionResult RegisterForm() + { + return View ("Register"); + } + /// /// Register the specified model and returnUrl. /// /// Model. /// Return URL. + [HttpPost] public ActionResult Register (RegisterViewModel model, string returnUrl) { ViewData ["returnUrl"] = returnUrl; @@ -142,7 +135,8 @@ namespace Yavsc.Controllers foreach (string k in ModelState.Keys) ModelState [k].Errors.Clear (); return View (model); - } + } + if (ModelState.IsValid) { if (model.ConfirmPassword != model.Password) { ModelState.AddModelError ("ConfirmPassword", "Veuillez confirmer votre mot de passe"); @@ -168,7 +162,7 @@ namespace Yavsc.Controllers "déjà enregistré"); return View (model); case MembershipCreateStatus.Success: - YavscHelpers.SendActivationMessage (user); + Url.SendActivationMessage (user); ViewData ["username"] = user.UserName; ViewData ["email"] = user.Email; return View ("RegistrationPending"); @@ -207,14 +201,20 @@ namespace Yavsc.Controllers } /// - /// Unregister the specified confirmed. + /// Unregister the specified id and confirmed. /// + /// Identifier. /// If set to true confirmed. [Authorize] - public ActionResult Unregister (bool confirmed = false) + public ActionResult Unregister (string id, bool confirmed = false) { + ViewData ["UserName"] = id; if (!confirmed) return View (); + string logged = Membership.GetUser ().UserName; + if (logged != id) + if (!Roles.IsUserInRole ("Admin")) + throw new Exception ("Unregister another user"); Membership.DeleteUser ( Membership.GetUser ().UserName); @@ -391,9 +391,13 @@ namespace Yavsc.Controllers { if (Request.HttpMethod == "POST") { StringDictionary errors; - YavscHelpers.ResetPassword (model, out errors); + MembershipUser user; + YavscHelpers.ValidatePasswordReset (model, out errors, out user); foreach (string key in errors.Keys) ModelState.AddModelError (key, errors [key]); + + if (user != null && ModelState.IsValid) + Url.SendActivationMessage (user); } return View (model); } diff --git a/web/Controllers/AdminController.cs b/web/Controllers/AdminController.cs index 2190527b..f2cede23 100644 --- a/web/Controllers/AdminController.cs +++ b/web/Controllers/AdminController.cs @@ -43,6 +43,10 @@ namespace Yavsc.Controllers datac.BackupPrefix = Server.MapPath (datac.BackupPrefix); DataManager mgr = new DataManager (datac); TaskOutput tcdb = mgr.CreateDb (); + ViewData ["DbName"] = datac.DbName; + ViewData ["DbUser"] = datac.DbUser; + ViewData ["Host"] = datac.Host; + ViewData ["Port"] = datac.Port; return View ("Created", tcdb); } } diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs index 29c01273..29985fb4 100644 --- a/web/Controllers/BlogsController.cs +++ b/web/Controllers/BlogsController.cs @@ -185,8 +185,8 @@ namespace Yavsc.Controllers ViewData ["Avatar"] = pr.avatar; ViewData ["BlogTitle"] = pr.BlogTitle; MembershipUser u = Membership.GetUser (); - if (u != null) - ViewData ["Author"] = u.UserName; + + ViewData ["Author"] = bec.Author; if (!pr.BlogVisible) { // only deliver to admins or owner if (u == null) @@ -197,6 +197,13 @@ namespace Yavsc.Controllers return View ("NotAuthorized"); } } + if (u == null || (u.UserName != bec.Author) && !Roles.IsUserInRole (u.UserName, "Admin")) { + // Filer on allowed posts + BlogEntryCollection filtered = bec.FilterFor((u == null)?null : u.UserName); + UUTBlogEntryCollection nbec = new UUTBlogEntryCollection (bec.Author, bec.Title); + nbec.AddRange (filtered); + View ("UserPost",nbec); + } } return View ("UserPost",bec); } diff --git a/web/Helpers/YavscHelpers.cs b/web/Helpers/YavscHelpers.cs index d6bf7ff0..f7f6dd8c 100644 --- a/web/Helpers/YavscHelpers.cs +++ b/web/Helpers/YavscHelpers.cs @@ -5,11 +5,9 @@ using System.Web.Security; using System.IO; using System.Web.Configuration; using System.Net.Mail; -using System.Web.Http.ModelBinding; using Yavsc.Model.RolesAndMembers; using System.Collections.Generic; using System.Collections.Specialized; -using System.Web.Mvc; using Yavsc.Model.Circles; using System.Web.UI; using System.Linq.Expressions; @@ -23,31 +21,6 @@ namespace Yavsc.Helpers /// public static class YavscHelpers { - /// - /// Formats the circle. - /// - /// The circle. - /// C. - public static HtmlString FormatCircle (Circle c) - { - if (c.Members!=null) - if (c.Members.Length > 0) { - TagBuilder i = new TagBuilder ("i"); - i.SetInnerText (String.Join (", ", c.Members)); - return new HtmlString (c.Title+"
\n"+i.ToString()); - } - return new HtmlString (c.Title); - } - /// - /// Formats the circle. - /// - /// The circle as Html string. - /// Helper. - /// C. - public static HtmlString FormatCircle(this HtmlHelper helper, Circle c) - { - return FormatCircle (c); - } private static string siteName = null; /// @@ -77,19 +50,33 @@ namespace Yavsc.Helpers /// /// Sends the activation message. /// + /// Helper. /// User. - public static void SendActivationMessage(MembershipUser user) + public static void SendActivationMessage(this System.Web.Http.Routing.UrlHelper helper, MembershipUser user) { - SendEmail (WebConfigurationManager.AppSettings ["RegistrationMessage"], + SendActivationMessage (helper.Route("~/Account/Validate/",new { id=user.UserName, key=user.ProviderUserKey.ToString() } ) + , WebConfigurationManager.AppSettings ["RegistrationMessage"], + user); + } + /// + /// Sends the activation message. + /// + /// Helper. + /// User. + public static void SendActivationMessage(this System.Web.Mvc.UrlHelper helper, MembershipUser user) + { + SendActivationMessage (helper.Content("~/Account/Validate/"+user.UserName+"/?key="+user.ProviderUserKey.ToString()) + , WebConfigurationManager.AppSettings ["RegistrationMessage"], user); } /// - /// Sends the email. + /// Sends the activation message. /// + /// Validation URL. /// Registration message. /// User. - public static void SendEmail(string registrationMessage, MembershipUser user) { + public static void SendActivationMessage(string validationUrl, string registrationMessage, MembershipUser user) { FileInfo fi = new FileInfo ( HttpContext.Current.Server.MapPath (registrationMessage)); if (!fi.Exists) { @@ -104,12 +91,8 @@ namespace Yavsc.Helpers string body = sr.ReadToEnd (); body = body.Replace ("<%SiteName%>", YavscHelpers.SiteName); body = body.Replace ("<%UserName%>", user.UserName); - body = body.Replace ("<%UserActivatonUrl%>", - string.Format ("<{0}://{1}/Account/Validate/{2}?key={3}>", - HttpContext.Current.Request.Url.Scheme, - HttpContext.Current.Request.Url.Authority, - user.UserName, - user.ProviderUserKey.ToString ())); + body = body.Replace ("<%UserActivatonUrl%>", validationUrl); + using (MailMessage msg = new MailMessage ( Admail, user.Email, string.Format ("Validation de votre compte {0}", YavscHelpers.SiteName), @@ -123,15 +106,16 @@ namespace Yavsc.Helpers } /// - /// Resets the password. + /// Validates the password reset. /// /// Model. /// Errors. - public static void ResetPassword(LostPasswordModel model, out StringDictionary errors) + /// User. + public static void ValidatePasswordReset(LostPasswordModel model, out StringDictionary errors, out MembershipUser user) { MembershipUserCollection users = null; errors = new StringDictionary (); - + user = null; if (!string.IsNullOrEmpty (model.UserName)) { users = Membership.FindUsersByName (model.UserName); @@ -159,10 +143,7 @@ namespace Yavsc.Helpers if (users==null) return; // Assert users.Count == 1 - if (users.Count != 1) - throw new InvalidProgramException ("Emails and user's names are uniques, and we find more than one result here, aborting."); - foreach (MembershipUser u in users) - YavscHelpers.SendActivationMessage (u); + foreach (MembershipUser u in users) user = u; } /// /// Avatars the URL. @@ -170,11 +151,19 @@ namespace Yavsc.Helpers /// The URL. /// Helper. /// Username. - public static string AvatarUrl (this HtmlHelper helper, string username) { + public static string AvatarUrl (this System.Web.Mvc.UrlHelper helper, string username) { + if (username == null) + return null; ProfileBase pr = ProfileBase.Create (username); - var a = pr.GetPropertyValue("Avatar") ; - if (a == null || a is DBNull) return "/avatars/" + helper.Encode(username)+".png"; - return helper.Encode ((string)a); + object avpath = null; + if (pr != null) avpath = pr.GetPropertyValue("Avatar"); + if (avpath == null) return "/bfiles/"+username+".png"; + string avatarLocation = avpath as string; + if (avatarLocation.StartsWith ("~/")) { + avatarLocation = helper.RequestContext.HttpContext.Server.MapPath(avatarLocation); + } + return avatarLocation; + } /// /// Javas the script. diff --git a/web/Models/App.master b/web/Models/App.master index 41bc220d..13a1fda4 100644 --- a/web/Models/App.master +++ b/web/Models/App.master @@ -26,7 +26,7 @@ var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
-

+

"> <%=ViewState["orgtitle"]%> - "><%= YavscHelpers.SiteName %> @@ -51,8 +51,7 @@ Yavsc.notice('<%=notice%>'); <% } else { %> - -vos billets +vos billets Vos billets " accesskey="L" class="menuitem"> diff --git a/web/Views/Account/Login.aspx b/web/Views/Account/Login.aspx index 00306c42..ba09a7da 100644 --- a/web/Views/Account/Login.aspx +++ b/web/Views/Account/Login.aspx @@ -20,7 +20,7 @@ <% } %>
-<%= Html.ActionLink("S'enregistrer","Register",new {returnUrl=ViewData["returnUrl"]}, new { @class="actionlink" }) %> +<%= Html.ActionLink("S'enregistrer","RegisterForm",new {returnUrl=ViewData["returnUrl"]}, new { @class="actionlink" }) %>
?returnUrl=<%=ViewData["returnUrl"]==null?Request.Url.PathAndQuery:(string)ViewData["returnUrl"]%>" class="actionlink"> diff --git a/web/Views/Account/Profile.aspx b/web/Views/Account/Profile.aspx index 0aac44b0..8319cff7 100644 --- a/web/Views/Account/Profile.aspx +++ b/web/Views/Account/Profile.aspx @@ -117,7 +117,7 @@ Avatar :

/// The dbname. - public string Dbname { + public string DbName { get { return dbname; } @@ -62,7 +62,7 @@ namespace Yavsc.Model.Admin /// Gets or sets the dbuser. ///
/// The dbuser. - public string Dbuser { + public string DbUser { get { return dbuser; } @@ -101,7 +101,7 @@ namespace Yavsc.Model.Admin ///
/// The string. public string ConnectionString { get { return string.Format ("Server={0};Port={1};Database={2};User Id={3};Password={4};Encoding=Unicode;", - Host, Port, Dbname, Dbuser, Password); } } + Host, Port, DbName, DbUser, Password); } } } } diff --git a/yavscModel/Blogs/BlogEntryCollection.cs b/yavscModel/Blogs/BlogEntryCollection.cs index e0306b59..31b33017 100644 --- a/yavscModel/Blogs/BlogEntryCollection.cs +++ b/yavscModel/Blogs/BlogEntryCollection.cs @@ -3,6 +3,7 @@ using System.Configuration; using System.Collections.Generic; using Yavsc.Model.Blogs; using System.Linq; +using Yavsc.Model.Circles; namespace Yavsc.Model.Blogs { @@ -56,7 +57,25 @@ namespace Yavsc.Model.Blogs { return this.Where (x => x.Title == title).ToArray (); } - + /// + /// Filters the current collection for a given user by its name. + /// Assumes that this user is not an author of any of these posts. + /// + /// Username. + public BlogEntryCollection FilterFor(string username) + { + BlogEntryCollection res = new BlogEntryCollection (); + foreach (BlogEntry be in this) { + if (be.Visible && + (be.AllowedCircles == null || + (username!= null && CircleManager.DefaultProvider.Matches + (be.AllowedCircles,username)))) + { + res.Add(be); + } + } + return res; + } /// /// Base post info. /// diff --git a/yavscModel/ChangeLog b/yavscModel/ChangeLog deleted file mode 100644 index 71a2973b..00000000 --- a/yavscModel/ChangeLog +++ /dev/null @@ -1,321 +0,0 @@ -2015-10-09 Paul Schneider - - * LocalizedText.resx: - * LocalizedText.fr.resx: - * LocalizedText.Designer.cs: - * LocalizedText.fr.Designer.cs: a new translation - -2015-10-08 Paul Schneider - - * BlogEntry.cs: defines the photo in the model - - * BlogManager.cs: a new method to set the photo on a blog - post. - - * BlogProvider.cs: the blog provider now also gives some photo - - * LocalizedText.fr.Designer.cs: Reordering the french - localisation resource - - * LocalizedText.fr.resx: Reorders the french localisation - resource - -2015-10-04 Paul Schneider - - * MarkdownHelper.cs: - * BlogEntryCollection.cs: refactoring + extract an intro from - Markdown for PostInfo* - - * YavscModel.csproj: MarkdownHelper integration - -2015-10-01 Paul Schneider - - * Profile.cs: refactoring - -2015-09-30 Paul Schneider - - * Profile.cs: Groups profile properties - - * ChangeLog: Must not exist in the source tree - -2015-09-30 Paul Schneider - - * Profile.cs: Grouping profile properties - -2015-09-23 Paul Schneider - - * BlogEntry.cs: - * BlogManager.cs: - * BlogEntryCollection.cs: - * UUBlogEntryCollection.cs: - * UUTBlogEntryCollection.cs: refactoring - -2015-09-16 Paul Schneider - - * LocalizedText.resx: - * LocalizedText.fr.resx: - * LocalizedText.Designer.cs: - * LocalizedText.fr.Designer.cs: - -2015-09-11 Paul Schneider - - * BlogManager.cs: Any user may edit any title - -2015-09-10 Paul Schneider - - * CircleBase.cs: - -2015-09-10 Paul Schneider - - * CircleBase.cs: The Circle base - - * Circle.cs: Now inherits CircleBase to implement a member - list - - * CircleProvider.cs: implements a circle update method - - - * LocalizedText.resx: - * LocalizedText.Designer.cs: no content!!! - - * LocalizedText.fr.resx: - * LocalizedText.fr.Designer.cs: pas content - - * YavscModel.csproj: a new CircleBAse class - -2015-08-22 Paul Schneider - - * LocalizedText.Designer.cs: alphabetic order in ressource - names - - * LocalizedText.resx: * alphabetic order in ressource names - - * RegisterModel.cs: disposes a duplicated resource string - "UserName" (uses now User_name) - -2015-08-20 Paul Schneider - - * BlogEntryCollection.cs: cleans used code - -2015-08-20 Paul Schneider - - * BlogEntryCollection.cs: ConcernsAUniqueTitle and - ConcernsAUniqueUser are now Obsoletes - - * UUTBlogEntryCollection.cs: Drops a useless ctor - - * CircleProvider.cs: The `CircleManager` now delivers the - user's circle as a `Circle` object collection. - -2015-08-14 Paul Schneider - - * FileSystemManager.cs: * Fixes the dir separator usage - * Adds a method to validate a directory or file name - - * YavscModel.csproj: - * Commande.cs: FileInfoCollection is now removed - - * FileInfoCollection.cs: - * DirNotFoundException.cs: Removes useless code - -2015-08-05 Paul Schneider - - * BlogEntryCollection.cs: adds xml doc - - * UUBlogEntryCollection.cs: - * UUTBlogEntryCollection.cs: fixes a creation from a post - array - -2015-08-05 Paul Schneider - - * BlogManager.cs: fixes the comment posting - -2015-08-04 Paul Schneider - - * BlogEntryCollection.cs: implement the BlogEntryCollection - - * BlogManager.cs: the manager helps to filter on access - - * BlogProvider.cs: The title is not unique anymore, and one - can modify it, post a lot under it, drop all posts under it. - A Post is deleted by id. - - * UUBlogEntryCollection.cs: implements a collection of post - under a given user name. - - * UUTBlogEntryCollection.cs: implements a collection of post - under a given couple (user name, title). - - * IDbModule.cs: - * WorkFlowManager.cs: refactoring - - * ListItem.cs: ListItem is declared obsolete in this model, - helpers can build MVC SelectListItem on data returned by the - manager. - - * LocalizedText.Designer.cs: - * LocalizedText.fr.Designer.cs: autogenerated from xml - - * LocalizedText.resx: - * LocalizedText.fr.resx: new labels - - * ChangeUserNameProvider.cs: xml doc - - * Profile.cs: the UserName property is read only, and comes - from authentication, to change it, we set a Name and validate - it agains the "Profile" method - - - * UserManager.cs: simpler code a init time - - * IContentProvider.cs: implements the new IDataProvider - interface - - * IDataProvider.cs: defines the new IDataProvider interface - - * YavscModel.csproj: includes new classes - -2015-07-17 Paul Schneider - - * YavscModel.csproj: - * Automate.cs: - * TaskOutput.cs: - * Service.cs: - * FinalStateException.cs: - * InvalidLetterException.cs: - * PriceOnItemCount.cs: - -2015-07-15 Paul Schneider - - * ListItem.cs: - * Circle.cs: - * BlogHelper.cs: - * BlogManager.cs: - * BookEdit.cs: - * FreeDate.cs: - * BlogProvider.cs: - - * YavscModel.csproj: Moves to Mono framework - -2015-07-02 Paul Schneider - - * ListItem.cs: - * YavscModel.csproj: - * BlogEntry.cs: - * BlogManager.cs: - * BlogProvider.cs: - * CircleManager.cs: - * CircleProvider.cs: - * SimpleMessage.cs: - -2015-06-26 Paul Schneider - - * Period.cs: - * WeekDay.cs: - * OpenDay.cs: - * YaEvent.cs: - * Schedule.cs: - * EventPub.cs: - * Position.cs: - * Periodicity.cs: - * ProvidedEvent.cs: - * PositionAndKeyphrase.cs: - * ProviderPublicInfo.cs: refactoring - -2015-06-18 Paul Schneider - - * RegisterClientModel.cs: Implements the Question and answer - in the registration model - -2015-06-18 Paul Schneider - - * YavscModel.csproj: - * LocalizedText.resx: - * LocalizedText.fr.resx: - * LocalizedText.Designer.cs: - * Profile.cs: - * Profile.cs: - * LocalizedText.fr.Designer.cs: - * LoginModel.cs: - * Publishing.cs: - * LoginModel.cs: - * Publishing.cs: - * GCMRegister.cs: - * NewRoleModel.cs: - * GCMRegister.cs: - * NewRoleModel.cs: - * NewAdminModel.cs: - * RegisterModel.cs: - * NewAdminModel.cs: - * RegisterModel.cs: - * RegisterViewModel.cs: - * LostPasswordModel.cs: - * ProviderPublicInfo.cs: - * RegisterViewModel.cs: - * ProviderPublicInfo.cs: - * ChangePasswordModel.cs: - * RegisterClientModel.cs: - * RegisterClientModel.cs: - * ChangePasswordModel.cs: - -2015-06-12 Paul Schneider - - * YavscModel.csproj: - * BlogHelper.cs: - * CircleManager.cs: - * WorkFlowManager.cs: - * NewEstimateEvenArgs.cs: - * Provider.cs: - * DataProviderConfigurationSection.cs: - * ProviderCollection.cs: - * WorkflowConfiguration.cs: - * BlogProviderConfigurationElement.cs: - * BlogProvidersConfigurationSection.cs: - * BlogProvidersConfigurationCollection.cs: - * CatalogProvidersConfigurationSection.cs: - -2015-06-10 Paul Schneider - - * Circle.cs: refactoring - - * CircleInfo.cs: - * CircleProvider.cs: - - * Profile.cs: User's profile does not contain anymore the main - e-mail address, it conflicts with registration informations, - it is not part of the profile data - -2015-06-10 Paul Schneider - - * CircleManager.cs: initializes the default provider - - * CircleProvider.cs: Makes abstract the CircleProvider class - -2015-06-10 Paul Schneider - - * Circle.cs: - * CircleInfo.cs: - * CircleInfoCollection.cs: cleans imports - - * CircleManager.cs: implements a circle manager - - * CircleProvider.cs: Defines a default Circle provider - - * EventPub.cs: refactoring - - * YavscModel.csproj: Includes Circle provider definitions - -2015-06-09 Paul Schneider - - * LocalizedText.resx: - * LocalizedText.Designer.cs: - * LocalizedText.fr.Designer.cs: - - * LocalizedText.fr.resx: Page Title - -2015-06-09 Paul Schneider - - * YavscModel.csproj: - * BlogEditEntryModel.cs: - * BlogEditCommentModel.cs: - diff --git a/yavscModel/WorkFlow/TaskOutput.cs b/yavscModel/WorkFlow/TaskOutput.cs index 50318b55..fc9a192c 100644 --- a/yavscModel/WorkFlow/TaskOutput.cs +++ b/yavscModel/WorkFlow/TaskOutput.cs @@ -1,7 +1,7 @@ using System; using System.ComponentModel; -namespace Yavsc.Admin +namespace Yavsc.Model.Admin { ///