* bg.gif:
* asc.gif: * desc.gif: * style.css: moved to App_Themes * style.css: * bg.gif: * asc.gif: * bg.png: * rect.png: * asc.png: * desc.gif: * jquery-ui.css: * mdd_styles.css: * croix.png: * desc.png: * style.css: * jquery-ui.min.css: * mdd_gripper.png: * mdd_toolbar.png: * jquery.timepicker.css: * mdd_ajax_loader.gif: * mdd_modal_background.png: moved to /App_Themes * NpgsqlBlogProvider.cs: * Remove post by id * Manage collections of entries on a couple (user,title), not a single post * NpgsqlCircleProvider.cs: Fixes the "Match" method. * IDbModule.cs: * Edit.aspx: * Estimates.aspx: * WorkFlowManager.cs: * NpgsqlContentProvider.cs: refactoring * NpgsqlMRPProviders.csproj: new NpgsqlUserName provider * NpgsqlRoleProvider.cs: simpler init method * NpgsqlUserNameProvider.cs: impements a UserNameProvider * MyClass.cs: refactoring from Yavsc.Model * BlogsController.cs: access control simplified * FrontOfficeController.cs: Pdf generation made public ni case of formatting exception * mdd_styles.css: Theme -> App_Themes * style.css: yet another style impact * AccountController.cs: Fixes the user name modification * BlogsController.cs: * Fixes the removal process * On a title and user name, we get collection of posts, not only one. * Implements an Access on circle * FrontOfficeController.cs: * implements a new Get method. * ensure a membership existence before delivering an estimate. * GoogleController.cs: Fixes the user name modification on a Google account * ErrorHtmlFormatter.cs: nice error message in html (using Markdown helper) * FormatterException.cs: formatter exception exposes error and standard output of the process * TexToPdfFormatter.cs: * generates temporary files in the folder returned by Path.GetTempPath() * throws FormatterException * Global.asax.cs: new route map: Blogs/{action}/{user}/{title} Blog/{user}/{title} B/{id} {controller}/{action}/{id} * App.master: * refactoring: Theme moved to App_Themes * a link to the logged user's blog * * NoLogin.master: refactoring: Theme moved to App_Themes * Circles.aspx: refactoring : circles now are given as select items * Login.aspx: fixes the html presentation * Register.aspx: Fixes a Typo * Index.aspx: Implements a blog index, due to M&C changes with this commit * RemovePost.aspx: links to the new route to the "RemovePost" action, giving it a post id * RemoveTitle.aspx: fixes a not yet linked page to remove a post collection under a given title * EventPub.aspx: code refactoring * Writting.ascx: cleans the code * Web.config: fills the config with new names in the space * Web.config: configures the new NpgsqlUserNameProvider * Web.csproj: refactoring and others * 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). * 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 * UserPosts.aspx: adds a link to remove a post * UserPost.aspx: now uses the new BlogEntryCollection object
This commit is contained in:
@ -2,6 +2,7 @@ using System;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Model.Blogs;
|
||||
using System.Linq;
|
||||
|
||||
namespace Yavsc.Model.Blogs
|
||||
{
|
||||
@ -10,6 +11,155 @@ namespace Yavsc.Model.Blogs
|
||||
/// </summary>
|
||||
public class BlogEntryCollection : List<BlogEntry>
|
||||
{
|
||||
public BlogEntryCollection ()
|
||||
{
|
||||
}
|
||||
|
||||
public BlogEntryCollection(IEnumerable<BlogEntry> items)
|
||||
{
|
||||
if (items!=null)
|
||||
this.AddRange (items);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/>.</returns>
|
||||
public override string ToString ()
|
||||
{
|
||||
string titles = Titles == null ?
|
||||
"none" : string.Join (", ", Titles);
|
||||
return string.Format ("[BlogEntryCollection: Titles={0}]", titles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the specified bid.
|
||||
/// </summary>
|
||||
/// <param name="bid">Bid.</param>
|
||||
public BlogEntry Get (long bid)
|
||||
{
|
||||
return this.First (x => x.Id == bid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filters this collection on
|
||||
/// the given title.
|
||||
/// </summary>
|
||||
/// <returns>The by title.</returns>
|
||||
/// <param name="title">Title.</param>
|
||||
public BlogEntry [] FilterOnTitle (string title)
|
||||
{
|
||||
return this.Where (x => x.Title == title).ToArray ();
|
||||
}
|
||||
/// <summary>
|
||||
/// Post info.
|
||||
/// </summary>
|
||||
public struct PostInfoByTitle {
|
||||
|
||||
/// <summary>
|
||||
/// The name of the user.
|
||||
/// </summary>
|
||||
public string UserName;
|
||||
/// <summary>
|
||||
/// The identifier.
|
||||
/// </summary>
|
||||
public long Id;
|
||||
/// <summary>
|
||||
/// The posted.
|
||||
/// </summary>
|
||||
public DateTime Posted;
|
||||
/// <summary>
|
||||
/// The modified.
|
||||
/// </summary>
|
||||
public DateTime Modified;
|
||||
|
||||
}
|
||||
public struct PostInfoByUser {
|
||||
|
||||
/// <summary>
|
||||
/// The name of the user.
|
||||
/// </summary>
|
||||
public string Title;
|
||||
/// <summary>
|
||||
/// The identifier.
|
||||
/// </summary>
|
||||
public long Id;
|
||||
/// <summary>
|
||||
/// The posted.
|
||||
/// </summary>
|
||||
public DateTime Posted;
|
||||
/// <summary>
|
||||
/// The modified.
|
||||
/// </summary>
|
||||
public DateTime Modified;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Groups by title.
|
||||
/// </summary>
|
||||
public IEnumerable<IGrouping<string,PostInfoByTitle>> GroupByTitle()
|
||||
{
|
||||
return from be in this
|
||||
orderby be.Posted descending
|
||||
group
|
||||
new PostInfoByTitle { UserName=be.UserName, Id=be.Id,
|
||||
Posted=be.Posted, Modified=be.Modified }
|
||||
by be.Title
|
||||
into titlegroup
|
||||
select titlegroup;
|
||||
}
|
||||
/// <summary>
|
||||
/// Groups by user.
|
||||
/// </summary>
|
||||
/// <returns>The by user.</returns>
|
||||
public IEnumerable<IGrouping<string,PostInfoByUser>> GroupByUser()
|
||||
{
|
||||
return from be in this
|
||||
orderby be.Posted descending
|
||||
group
|
||||
new PostInfoByUser { Title=be.Title, Id=be.Id,
|
||||
Posted=be.Posted, Modified=be.Modified }
|
||||
by be.UserName
|
||||
into usergroup
|
||||
select usergroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the titles.
|
||||
/// </summary>
|
||||
/// <value>The titles.</value>
|
||||
public string[] Titles { get {
|
||||
string[] result = this.Select (x => x.Title).Distinct ().ToArray ();
|
||||
if (result == null)
|
||||
return new string[0];
|
||||
return result;
|
||||
} }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/> concerns A unique title.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if concerns A unique title; otherwise, <c>false</c>.</value>
|
||||
public bool ConcernsAUniqueTitle {
|
||||
get {
|
||||
if (this.Count <= 1)
|
||||
return true;
|
||||
else
|
||||
return this.All (x => Titles [0] == x.Title);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/> concerns A unique title.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if concerns A unique title; otherwise, <c>false</c>.</value>
|
||||
public bool ConcernsAUniqueUser {
|
||||
get {
|
||||
if (this.Count <= 1)
|
||||
return true;
|
||||
else
|
||||
return this.All (x => x.UserName == this[0].UserName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ using System.Web;
|
||||
using System.Web.Security;
|
||||
using Yavsc.Model.Circles;
|
||||
using System.Web.Mvc;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace Yavsc.Model.Blogs
|
||||
@ -56,7 +59,7 @@ namespace Yavsc.Model.Blogs
|
||||
/// <returns>The post.</returns>
|
||||
/// <param name="username">Username.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
public static BlogEntry GetPost (string username, string title)
|
||||
public static UUTBlogEntryCollection GetPost (string username, string title)
|
||||
{
|
||||
return Provider.GetPost (username, title);
|
||||
}
|
||||
@ -79,7 +82,7 @@ namespace Yavsc.Model.Blogs
|
||||
/// <param name="content">Content.</param>
|
||||
/// <param name="visible">If set to <c>true</c> visible.</param>
|
||||
/// <param name="cids">sets the circles.</param>
|
||||
public static long Post (string username, string title, string content, bool visible, long [] cids)
|
||||
public static long Post (string username, string title, string content, bool visible, long[] cids)
|
||||
{
|
||||
return Provider.Post (username, title, content, visible, cids);
|
||||
}
|
||||
@ -92,9 +95,9 @@ namespace Yavsc.Model.Blogs
|
||||
/// <param name="content">Content.</param>
|
||||
/// <param name="visible">If set to <c>true</c> visible.</param>
|
||||
/// <param name="cids">sets the circles.</param>
|
||||
public static void UpdatePost (long postid, string title, string content, bool visible,long [] cids)
|
||||
public static void UpdatePost (long postid, string title, string content, bool visible, long[] cids)
|
||||
{
|
||||
Provider.UpdatePost (postid, title, content, visible,cids);
|
||||
Provider.UpdatePost (postid, title, content, visible, cids);
|
||||
}
|
||||
|
||||
|
||||
@ -113,23 +116,32 @@ namespace Yavsc.Model.Blogs
|
||||
return Provider.FindPost (readersName, pattern, searchflags, pageIndex, pageSize, out totalRecords);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the post.
|
||||
/// </summary>
|
||||
/// <param name="post_id">Post identifier.</param>
|
||||
public static void RemovePost (long post_id)
|
||||
{
|
||||
Provider.RemovePost (post_id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the post.
|
||||
/// </summary>
|
||||
/// <param name="username">Username.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
public static void RemovePost (string username, string title)
|
||||
public static void RemoveTitle (string username, string title)
|
||||
{
|
||||
if (!Roles.IsUserInRole ("Admin")) {
|
||||
string rguser = Membership.GetUser ().UserName;
|
||||
if (rguser != username) {
|
||||
throw new AccessViolationException (
|
||||
string.Format (
|
||||
"{1}, Vous n'avez pas le droit de suprimer des billets du Blog de {0}",
|
||||
"{1}, Vous n'avez pas le droit de suprimer les Blogs de {0}",
|
||||
username, rguser));
|
||||
}
|
||||
}
|
||||
Provider.RemovePost (username, title);
|
||||
Provider.RemoveTitle (username, title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -139,9 +151,10 @@ namespace Yavsc.Model.Blogs
|
||||
/// <param name="pageIndex">Page index.</param>
|
||||
/// <param name="pageSize">Page size.</param>
|
||||
/// <param name="totalRecords">Total records.</param>
|
||||
public static BlogEntryCollection LastPosts (int pageIndex, int pageSize, out int totalRecords)
|
||||
public static IEnumerable<BlogEntry> LastPosts (int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
return Provider.LastPosts (pageIndex, pageSize, out totalRecords);
|
||||
var c = Provider.LastPosts (pageIndex, pageSize, out totalRecords);
|
||||
return FilterOnReadAccess (c);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -166,6 +179,136 @@ namespace Yavsc.Model.Blogs
|
||||
return Provider.Tag (postid, tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the auth can edit.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if can edit was authed, <c>false</c> otherwise.</returns>
|
||||
/// <param name="user">User.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
|
||||
public static bool CheckAuthCanEdit (string user, string title, bool throwEx = true)
|
||||
{
|
||||
BlogEntryCollection bec = BlogManager.GetPost (user, title);
|
||||
if (bec == null)
|
||||
throw new FileNotFoundException ();
|
||||
if (!Roles.IsUserInRole ("Admin"))
|
||||
if (bec.Count > 0)
|
||||
if (Membership.GetUser ().UserName != user) {
|
||||
if (throwEx)
|
||||
throw new AccessViolationException (
|
||||
string.Format (
|
||||
"Vous n'avez pas le droit d'editer ce blog (title:{0})",
|
||||
title));
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the auth can edit.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if auth can edit was checked, <c>false</c> otherwise.</returns>
|
||||
/// <param name="postid">Postid.</param>
|
||||
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
|
||||
public static BlogEntry GetForEditing (long postid, bool throwEx = true)
|
||||
{
|
||||
BlogEntry e = BlogManager.GetPost (postid);
|
||||
if (e == null)
|
||||
throw new PostNotFoundException ();
|
||||
if (!Roles.IsUserInRole ("Admin")) {
|
||||
string rguser = Membership.GetUser ().UserName;
|
||||
if (rguser != e.UserName) {
|
||||
if (throwEx)
|
||||
throw new AccessViolationException (
|
||||
string.Format (
|
||||
"Vous n'avez pas le droit d'editer ce billet (id:{0})",
|
||||
e.Id));
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
private static bool CanView (BlogEntry e, MembershipUser u = null)
|
||||
{
|
||||
if (e.AllowedCircles != null && e.AllowedCircles.Length > 0) {
|
||||
// only deliver to admins, owner, or specified circle memebers
|
||||
if (u == null)
|
||||
return false;
|
||||
if (u.UserName != e.UserName)
|
||||
if (!Roles.IsUserInRole (u.UserName, "Admin"))
|
||||
{
|
||||
if (!e.Visible)
|
||||
return false;
|
||||
if (!CircleManager.DefaultProvider.Matches (e.AllowedCircles, u.UserName))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Checks the auth can read.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if auth can read was checked, <c>false</c> otherwise.</returns>
|
||||
/// <param name="postid">Postid.</param>
|
||||
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
|
||||
public static BlogEntry GetForReading (long postid, bool throwEx = true)
|
||||
{
|
||||
BlogEntry e = BlogManager.GetPost (postid);
|
||||
if (e == null)
|
||||
if (throwEx)
|
||||
throw new FileNotFoundException ();
|
||||
if ( CanView (e, Membership.GetUser ()))
|
||||
return e;
|
||||
if (throwEx)
|
||||
throw new AccessViolationException (string.Format (
|
||||
"Vous n'avez pas le droit de lire ce billet (id:{0})",
|
||||
postid.ToString ()));
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the auth can read.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if auth can read was checked, <c>false</c> otherwise.</returns>
|
||||
/// <param name="bec">Bec.</param>
|
||||
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
|
||||
private static bool HasReadAccess (BlogEntryCollection bec, bool throwEx = true)
|
||||
{
|
||||
if (bec == null)
|
||||
throw new FileNotFoundException ();
|
||||
if (Roles.IsUserInRole ("Admin"))
|
||||
return true;
|
||||
var u = Membership.GetUser ();
|
||||
BlogEntry e = bec.First (x=>!CanView(x,u));
|
||||
if (e == null)
|
||||
return true;
|
||||
if (throwEx)
|
||||
throw new AccessViolationException (
|
||||
string.Format (
|
||||
"Vous n'avez pas le droit de lire cette collection de billet (titles:{0})",
|
||||
bec.ToString()));
|
||||
else
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Filters the on read access.
|
||||
/// </summary>
|
||||
/// <returns>The on read access.</returns>
|
||||
/// <param name="bec">Bec.</param>
|
||||
/// <typeparam name="TEntry">The 1st type parameter.</typeparam>
|
||||
public static IEnumerable<TEntry> FilterOnReadAccess<TEntry> ( IEnumerable<TEntry> bec)
|
||||
{
|
||||
if (bec == null) return null;
|
||||
if (Roles.IsUserInRole ("Admin")) return bec;
|
||||
var u = Membership.GetUser ();
|
||||
var r = bec.Where (x => CanView (x as BlogEntry, u));
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,15 +20,17 @@ namespace Yavsc.Model.Blogs
|
||||
public abstract BlogEntry GetPost (long postid);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the post.
|
||||
/// Gets the post collection from a given user and at a given title.
|
||||
/// </summary>
|
||||
/// <returns>The post.</returns>
|
||||
/// <param name="username">Username.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
public abstract BlogEntry GetPost (string username, string title);
|
||||
public abstract UUTBlogEntryCollection GetPost (string username, string title);
|
||||
|
||||
/// <summary>
|
||||
/// Post the specified username, title, content, visible and allowedCircles.
|
||||
/// Saves a post from the given username,
|
||||
/// at the specified title, this content,
|
||||
/// visible or not, and for allowedCircles.
|
||||
/// </summary>
|
||||
/// <param name="username">Username.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
@ -39,7 +41,8 @@ namespace Yavsc.Model.Blogs
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the post.
|
||||
/// Updates the post specified by its id,
|
||||
/// using the given title, content, visibility and circle collection.
|
||||
/// </summary>
|
||||
/// <param name="postid">Postid.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
@ -48,9 +51,8 @@ namespace Yavsc.Model.Blogs
|
||||
/// <param name="allowedCircles">Allowed circles.</param>
|
||||
public abstract void UpdatePost (long postid, string title, string content, bool visible, long[] allowedCircles);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds the post.
|
||||
/// Finds a post.
|
||||
/// </summary>
|
||||
/// <returns>The post.</returns>
|
||||
/// <param name="readersName">Readers name.</param>
|
||||
@ -63,11 +65,11 @@ namespace Yavsc.Model.Blogs
|
||||
int pageIndex, int pageSize, out int totalRecords);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the post.
|
||||
/// Removes the posts under the specified title and user.
|
||||
/// </summary>
|
||||
/// <param name="username">Username.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
public abstract void RemovePost (string username, string title);
|
||||
public abstract void RemoveTitle (string username, string title);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the post.
|
||||
@ -83,7 +85,7 @@ namespace Yavsc.Model.Blogs
|
||||
public abstract long RemoveComment (long cmtid);
|
||||
|
||||
/// <summary>
|
||||
/// Lasts the posts.
|
||||
/// Lasts the posts for this application.
|
||||
/// </summary>
|
||||
/// <returns>The posts.</returns>
|
||||
/// <param name="pageIndex">Page index.</param>
|
||||
@ -92,14 +94,15 @@ namespace Yavsc.Model.Blogs
|
||||
public abstract BlogEntryCollection LastPosts(int pageIndex, int pageSize, out int totalRecords);
|
||||
|
||||
/// <summary>
|
||||
/// Blogs the title.
|
||||
/// Returns the user's blog title.
|
||||
/// </summary>
|
||||
/// <returns>The title.</returns>
|
||||
/// <param name="username">Username.</param>
|
||||
public abstract string BlogTitle (string username);
|
||||
|
||||
/// <summary>
|
||||
/// Comment the specified from, postid and content.
|
||||
/// Saves a comment from specified user
|
||||
/// on the specided post using the specified content.
|
||||
/// </summary>
|
||||
/// <param name="from">From.</param>
|
||||
/// <param name="postid">Postid.</param>
|
||||
@ -107,7 +110,7 @@ namespace Yavsc.Model.Blogs
|
||||
public abstract long Comment (string from, long postid, string content);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the comments.
|
||||
/// Gets the comments on a specided post by identifier <c>postid</c>.
|
||||
/// </summary>
|
||||
/// <returns>The comments.</returns>
|
||||
/// <param name="postid">Postid.</param>
|
||||
@ -115,10 +118,10 @@ namespace Yavsc.Model.Blogs
|
||||
public abstract Comment[] GetComments (long postid, bool getHidden) ;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogProvider"/> auto validate comment.
|
||||
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogProvider"/> auto validates comments.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if auto validate comment; otherwise, <c>false</c>.</value>
|
||||
public abstract bool AutoValidateComment { get; set; }
|
||||
public abstract bool AutoValidatesComments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Validates the comment.
|
||||
@ -135,7 +138,8 @@ namespace Yavsc.Model.Blogs
|
||||
public abstract void UpdateComment (long cmtid, string content, bool visible);
|
||||
|
||||
/// <summary>
|
||||
/// Tag the specified postid and tag.
|
||||
/// Tag the specified post by identifier
|
||||
/// using the given tag.
|
||||
/// </summary>
|
||||
/// <param name="postid">Postid.</param>
|
||||
/// <param name="tag">Tag.</param>
|
||||
|
@ -34,12 +34,7 @@ namespace Yavsc.Model.Blogs
|
||||
/// <param name="username">Username.</param>
|
||||
/// <param name="items">Items.</param>
|
||||
public UUBlogEntryCollection(string username,
|
||||
BlogEntryCollection items = null) {
|
||||
if (items != null) {
|
||||
if (!items.ConcernsAUniqueUser)
|
||||
throw new InvalidOperationException ();
|
||||
this.AddRange (items);
|
||||
}
|
||||
BlogEntryCollection items = null) : base(items) {
|
||||
_username = username;
|
||||
}
|
||||
private string _username;
|
||||
@ -48,6 +43,11 @@ namespace Yavsc.Model.Blogs
|
||||
/// </summary>
|
||||
/// <value>The name of the user.</value>
|
||||
public string UserName { get { return _username; } }
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("[UUBlogEntryCollection: UserName={0} Count={1}]", UserName, Count);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,47 +18,46 @@
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Profile;
|
||||
using System.Web.Security;
|
||||
using Npgsql.Web.Blog;
|
||||
using Yavsc;
|
||||
using Yavsc.Model;
|
||||
using Yavsc.Model.Blogs;
|
||||
using Yavsc.ApiControllers;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
using System.Net;
|
||||
using System.Web.Mvc;
|
||||
using Yavsc.Model.Circles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
namespace Yavsc.Model.Blogs
|
||||
{
|
||||
public class UUTBlogEntryCollection : BlogEntryCollection {
|
||||
|
||||
UUTBlogEntryCollection(string username, string title,
|
||||
public BlogEntryCollection items = null) {
|
||||
if (items != null) {
|
||||
if (!items.ConcernsAUniqueTitle && items.ConcernsAUniqueTitle)
|
||||
/// <summary>
|
||||
/// Unique User and Title blog entry collection.
|
||||
/// </summary>
|
||||
public class UUTBlogEntryCollection : UUBlogEntryCollection {
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.Model.Blogs.UUTBlogEntryCollection"/> class.
|
||||
/// </summary>
|
||||
/// <param name="username">Username.</param>
|
||||
/// <param name="title">Title.</param>
|
||||
/// <param name="items">Items.</param>
|
||||
public UUTBlogEntryCollection(string username, string title,
|
||||
IEnumerable<BlogEntry> items = null) : base(username) {
|
||||
if (Count>0) {
|
||||
if (!(ConcernsAUniqueTitle && ConcernsAUniqueTitle))
|
||||
throw new InvalidOperationException ();
|
||||
this.AddRange (items);
|
||||
}
|
||||
_title = title;
|
||||
_username = username;
|
||||
}
|
||||
|
||||
private string _title;
|
||||
private string _username;
|
||||
public string UserName { get { return _username; } }
|
||||
/// <summary>
|
||||
/// Gets the title.
|
||||
/// </summary>
|
||||
/// <value>The title.</value>
|
||||
public string Title { get { return _title; } }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.UUTBlogEntryCollection"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.UUTBlogEntryCollection"/>.</returns>
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("[UUTBlogEntryCollection: " +
|
||||
"Title={0} User={1} Count={2}]", Title, UserName, Count);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,48 @@
|
||||
2015-08-04 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* 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 <paul@pschneider.fr>
|
||||
|
||||
* YavscModel.csproj:
|
||||
|
@ -9,7 +9,7 @@ namespace Yavsc.Model
|
||||
/// <summary>
|
||||
/// I module.
|
||||
/// </summary>
|
||||
public interface IModule
|
||||
public interface IDbModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Install the model in database using the specified cnx.
|
||||
|
@ -25,6 +25,7 @@ namespace Yavsc.Model
|
||||
/// <summary>
|
||||
/// List item.
|
||||
/// </summary>
|
||||
[Obsolete("Use MVC SelectItem")]
|
||||
public class ListItem
|
||||
{
|
||||
/// <summary>
|
||||
|
30
yavscModel/LocalizedText.Designer.cs
generated
30
yavscModel/LocalizedText.Designer.cs
generated
@ -46,6 +46,12 @@ namespace Yavsc.Model {
|
||||
}
|
||||
}
|
||||
|
||||
public static string Bill_edition {
|
||||
get {
|
||||
return ResourceManager.GetString("Bill_edition", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Tex_version {
|
||||
get {
|
||||
return ResourceManager.GetString("Tex_version", resourceCulture);
|
||||
@ -286,12 +292,6 @@ namespace Yavsc.Model {
|
||||
}
|
||||
}
|
||||
|
||||
public static string Bill_edition {
|
||||
get {
|
||||
return ResourceManager.GetString("Bill edition", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Offline {
|
||||
get {
|
||||
return ResourceManager.GetString("Offline", resourceCulture);
|
||||
@ -334,12 +334,30 @@ namespace Yavsc.Model {
|
||||
}
|
||||
}
|
||||
|
||||
public static string DisplayName {
|
||||
get {
|
||||
return ResourceManager.GetString("DisplayName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Consultant {
|
||||
get {
|
||||
return ResourceManager.GetString("Consultant", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InternalServerError {
|
||||
get {
|
||||
return ResourceManager.GetString("InternalServerError", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string entries {
|
||||
get {
|
||||
return ResourceManager.GetString("entries", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string DuplicateUserName {
|
||||
get {
|
||||
return ResourceManager.GetString("DuplicateUserName", resourceCulture);
|
||||
|
30
yavscModel/LocalizedText.fr.Designer.cs
generated
30
yavscModel/LocalizedText.fr.Designer.cs
generated
@ -46,6 +46,12 @@ namespace Yavsc.Model {
|
||||
}
|
||||
}
|
||||
|
||||
public static string Bill_edition {
|
||||
get {
|
||||
return ResourceManager.GetString("Bill_edition", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Tex_version {
|
||||
get {
|
||||
return ResourceManager.GetString("Tex_version", resourceCulture);
|
||||
@ -280,12 +286,6 @@ namespace Yavsc.Model {
|
||||
}
|
||||
}
|
||||
|
||||
public static string Bill_edition {
|
||||
get {
|
||||
return ResourceManager.GetString("Bill edition", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Offline {
|
||||
get {
|
||||
return ResourceManager.GetString("Offline", resourceCulture);
|
||||
@ -328,10 +328,28 @@ namespace Yavsc.Model {
|
||||
}
|
||||
}
|
||||
|
||||
public static string DisplayName {
|
||||
get {
|
||||
return ResourceManager.GetString("DisplayName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Consultant {
|
||||
get {
|
||||
return ResourceManager.GetString("Consultant", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InternalServerError {
|
||||
get {
|
||||
return ResourceManager.GetString("InternalServerError", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string entries {
|
||||
get {
|
||||
return ResourceManager.GetString("entries", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,8 +59,11 @@
|
||||
<data name="EventWebPage"><value>Page web de l'événement</value></data>
|
||||
<data name="ImgLocator"><value>URI de l'image</value></data>
|
||||
<data name="Home"><value>Accueil</value></data>
|
||||
<data name="Bill edition"><value>Édition d'un billet</value></data>
|
||||
<data name="Bill_edition"><value>Édition d'un billet</value></data>
|
||||
<data name="Create"><value>Créer</value></data>
|
||||
<data name="Members"><value>Membres</value></data>
|
||||
<data name="UserName"><value>Nom d'utilisateur</value></data>
|
||||
<data name="DisplayName"><value>Nom affiché</value></data>
|
||||
<data name="entries"><value>entrées</value></data>
|
||||
<data name="InternalServerError"><value>Erreur serveur interne</value></data>
|
||||
</root>
|
||||
|
@ -61,8 +61,12 @@
|
||||
<data name="EventWebPage"><value>Event Web page</value></data>
|
||||
<data name="ImgLocator"><value>Image URI</value></data>
|
||||
<data name="Home"><value>Home</value></data>
|
||||
<data name="Bill edition"><value>Bill edition</value></data>
|
||||
<data name="Bill_edition"><value>Bill edition</value></data>
|
||||
<data name="Create"><value>Create</value></data>
|
||||
<data name="Members"><value>Members</value></data>
|
||||
<data name="UserName"><value>User Name</value></data>
|
||||
<data name="DisplayName"><value>Display Name</value></data>
|
||||
<data name="entries"><value>entries</value></data>
|
||||
<data name="InternalServerError"><value>Internal Server Error</value></data>
|
||||
|
||||
</root>
|
||||
|
@ -37,9 +37,17 @@ namespace Yavsc.Model.RolesAndMembers
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the name.
|
||||
/// </summary>
|
||||
/// <param name="oldName">Old name.</param>
|
||||
/// <param name="newName">New name.</param>
|
||||
public abstract void ChangeName (string oldName, string newName) ;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance is name available the specified name.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if this instance is name available the specified name; otherwise, <c>false</c>.</returns>
|
||||
/// <param name="name">Name.</param>
|
||||
public abstract bool IsNameAvailable(string name);
|
||||
|
||||
}
|
||||
|
@ -213,11 +213,13 @@ namespace Yavsc.Model.RolesAndMembers
|
||||
&& string.IsNullOrWhiteSpace (Mobile));
|
||||
}
|
||||
}
|
||||
private string userName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the user.
|
||||
/// </summary>
|
||||
/// <value>The name of the user.</value>
|
||||
public string UserName { get ; set; }
|
||||
public string UserName { get { return userName; } }
|
||||
|
||||
public Profile () : base ()
|
||||
{
|
||||
@ -268,7 +270,7 @@ namespace Yavsc.Model.RolesAndMembers
|
||||
s = profile.GetPropertyValue ("Mobile");
|
||||
Mobile = (s is DBNull) ? null : (string)s;
|
||||
|
||||
UserName = profile.UserName;
|
||||
userName = profile.UserName;
|
||||
|
||||
s = profile.GetPropertyValue ("BankCode");
|
||||
BankCode = (s is DBNull) ? null : (string)s;
|
||||
|
@ -1,22 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Profile;
|
||||
using System.Web.Security;
|
||||
using Yavsc;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
using Yavsc.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using Yavsc.Model.Circles;
|
||||
using System.Collections.Specialized;
|
||||
using Yavsc.Model;
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
namespace Yavsc.Model.RolesAndMembers
|
||||
{
|
||||
/// <summary>
|
||||
/// User manager.
|
||||
@ -52,19 +38,27 @@ namespace Yavsc.Controllers
|
||||
/// <value>The provider.</value>
|
||||
public static ChangeUserNameProvider Provider {
|
||||
get {
|
||||
if (provider == null)
|
||||
provider = GetProvider ();
|
||||
if (provider == null)
|
||||
throw new ConfigurationErrorsException ("No username section defined");
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
|
||||
private static ChangeUserNameProvider GetProvider ()
|
||||
{
|
||||
DataProviderConfigurationSection config = ConfigurationManager.GetSection ("system.web/blog") as DataProviderConfigurationSection;
|
||||
DataProviderConfigurationSection config = ConfigurationManager.GetSection ("system.web/userNameManager") as DataProviderConfigurationSection;
|
||||
if (config == null)
|
||||
throw new ConfigurationErrorsException("The configuration bloc for the blog provider was not found");
|
||||
ProviderSettings celt =
|
||||
config.Providers[config.DefaultProvider];
|
||||
if (config == null)
|
||||
throw new ConfigurationErrorsException("The default blog provider was not found");
|
||||
throw new ConfigurationErrorsException("The configuration bloc for the username provider was not found");
|
||||
ProviderSettings celt=null;
|
||||
if (config.DefaultProvider!=null)
|
||||
celt = config.Providers[config.DefaultProvider];
|
||||
if ((celt == null) && config.Providers!=null)
|
||||
if (config.Providers.Count>0)
|
||||
celt = config.Providers [0];
|
||||
if (celt == null)
|
||||
throw new ConfigurationErrorsException("The default username provider was not found");
|
||||
ConstructorInfo ci = Type.GetType (celt.Type).GetConstructor (Type.EmptyTypes);
|
||||
provider = ci.Invoke (Type.EmptyTypes) as ChangeUserNameProvider;
|
||||
provider.Initialize (celt.Name, celt.Parameters);
|
||||
|
@ -8,7 +8,7 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// Interface content provider.
|
||||
/// Class Assertion: <c>Statuses.Length >= FinalStatuses.Length</c>.
|
||||
/// </summary>
|
||||
public interface IContentProvider : IModule, IDisposable
|
||||
public interface IContentProvider : IDbModule, IDisposable, IDataProvider<Estimate>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@ -55,12 +55,7 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// <param name="count">Cost multiplier.</param>
|
||||
/// <param name="productid">Product identifier.</param>
|
||||
long Write (long estid, string desc, decimal ucost, int count, string productid);
|
||||
/// <summary>
|
||||
/// Gets the estimate by identifier.
|
||||
/// </summary>
|
||||
/// <returns>The estimate.</returns>
|
||||
/// <param name="estimid">Estimid.</param>
|
||||
Estimate GetEstimate (long estimid);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the estimates created by
|
||||
/// or for the given user by user name.
|
||||
@ -103,11 +98,6 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// <param name="wr">Wr.</param>
|
||||
void UpdateWritting (Writting wr);
|
||||
/// <summary>
|
||||
/// Updates the estimate.
|
||||
/// </summary>
|
||||
/// <param name="estim">Estim.</param>
|
||||
void UpdateEstimate (Estimate estim);
|
||||
/// <summary>
|
||||
/// Sets the writting status.
|
||||
/// </summary>
|
||||
/// <param name="wrtid">Wrtid.</param>
|
||||
|
@ -4,8 +4,10 @@ using Yavsc.Model.FrontOffice;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow
|
||||
{
|
||||
public interface IDataProvider
|
||||
public interface IDataProvider<T>
|
||||
{
|
||||
T Get (long id);
|
||||
void Update (T data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// <param name="estim">Estim.</param>
|
||||
public void UpdateEstimate (Estimate estim)
|
||||
{
|
||||
ContentProvider.UpdateEstimate (estim);
|
||||
ContentProvider.Update (estim);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the estimate.
|
||||
@ -45,7 +45,7 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// <param name="estid">Estid.</param>
|
||||
public Estimate GetEstimate (long estid)
|
||||
{
|
||||
return ContentProvider.GetEstimate (estid);
|
||||
return ContentProvider.Get (estid);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the estimates, refering the
|
||||
|
@ -57,7 +57,6 @@
|
||||
<Compile Include="Blogs\Comment.cs" />
|
||||
<Compile Include="Blogs\FindBlogEntryFlags.cs" />
|
||||
<Compile Include="WorkFlow\StatusChange.cs" />
|
||||
<Compile Include="IModule.cs" />
|
||||
<Compile Include="Blogs\BlogManager.cs" />
|
||||
<Compile Include="Blogs\BlogProvider.cs" />
|
||||
<Compile Include="WorkFlow\WorkFlowManager.cs" />
|
||||
@ -163,6 +162,13 @@
|
||||
<Compile Include="WorkFlow\TaskOutput.cs" />
|
||||
<Compile Include="WorkFlow\FinalStateException.cs" />
|
||||
<Compile Include="WorkFlow\InvalidLetterException.cs" />
|
||||
<Compile Include="Blogs\UUTBlogEntryCollection.cs" />
|
||||
<Compile Include="Blogs\UUBlogEntryCollection.cs" />
|
||||
<Compile Include="IDbModule.cs" />
|
||||
<Compile Include="WorkFlow\IDataProvider.cs" />
|
||||
<Compile Include="Blogs\PostNotFoundException.cs" />
|
||||
<Compile Include="RolesAndMembers\ChangeUserNameProvider.cs" />
|
||||
<Compile Include="RolesAndMembers\UserManager.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user