WIP: A Blogger role
This commit is contained in:
parent
665b536aa7
commit
0e6da27309
3 changed files with 38 additions and 36 deletions
|
|
@ -145,7 +145,7 @@ namespace Yavsc.Controllers
|
|||
/// </summary>
|
||||
/// <returns>The comment.</returns>
|
||||
/// <param name="cmtid">Cmtid.</param>
|
||||
[Authorize]
|
||||
[Authorize(Roles="Blogger")]
|
||||
public ActionResult RemoveComment (long cmtid)
|
||||
{
|
||||
long postid = BlogManager.RemoveComment (cmtid);
|
||||
|
|
@ -257,7 +257,7 @@ namespace Yavsc.Controllers
|
|||
/// Post the specified title.
|
||||
/// </summary>
|
||||
/// <param name="title">Title.</param>
|
||||
[Authorize]
|
||||
[Authorize(Roles="Blogger")]
|
||||
public ActionResult Post (string title)
|
||||
{
|
||||
string un = Membership.GetUser ().UserName;
|
||||
|
|
@ -279,7 +279,7 @@ namespace Yavsc.Controllers
|
|||
/// </summary>
|
||||
/// <returns>The edit.</returns>
|
||||
/// <param name="model">Model.</param>
|
||||
[Authorize]
|
||||
[Authorize(Roles="Blogger")]
|
||||
public ActionResult ValidateEdit (BlogEntry model)
|
||||
{
|
||||
ViewData ["SiteName"] = sitename;
|
||||
|
|
@ -311,7 +311,7 @@ namespace Yavsc.Controllers
|
|||
/// Edit the specified bill
|
||||
/// </summary>
|
||||
/// <param name="id">Identifier.</param>
|
||||
[Authorize]
|
||||
[Authorize(Roles="Blogger")]
|
||||
public ActionResult Edit (long postid)
|
||||
{
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ namespace Yavsc.Controllers
|
|||
/// <param name="user">User.</param>
|
||||
/// <param name="returnUrl">Return URL.</param>
|
||||
/// <param name="confirm">If set to <c>true</c> confirm.</param>
|
||||
[Authorize]
|
||||
[Authorize(Roles="Blogger")]
|
||||
public ActionResult RemoveTitle (string user, string title, string returnUrl, bool confirm = false)
|
||||
{
|
||||
if (returnUrl == null)
|
||||
|
|
@ -389,7 +389,7 @@ namespace Yavsc.Controllers
|
|||
/// <param name="id">Identifier.</param>
|
||||
/// <param name="returnUrl">Return URL.</param>
|
||||
/// <param name="confirm">If set to <c>true</c> confirm.</param>
|
||||
[Authorize]
|
||||
[Authorize(Roles="Blogger")]
|
||||
public ActionResult RemovePost (long postid, string returnUrl, bool confirm = false)
|
||||
{
|
||||
// ensures the access control
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ namespace Yavsc.Controllers
|
|||
/// </summary>
|
||||
public class GoogleController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Index this instance.
|
||||
/// </summary>
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View ();
|
||||
|
|
@ -295,9 +298,9 @@ namespace Yavsc.Controllers
|
|||
/// <returns>The query.</returns>
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
public ActionResult DateQuery ()
|
||||
public ActionResult Book ()
|
||||
{
|
||||
return View (new BookEdit ());
|
||||
return View (new BookQuery ());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -307,42 +310,41 @@ namespace Yavsc.Controllers
|
|||
/// <param name="model">Model.</param>
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
public ActionResult DateQuery (BookEdit model)
|
||||
public ActionResult Book (BookQuery model)
|
||||
{
|
||||
if (ModelState.IsValid) {
|
||||
|
||||
DateTime mindate = DateTime.Now;
|
||||
if (model.PreferedDate < mindate)
|
||||
model.PreferedDate = mindate;
|
||||
if (model.MaxDate < mindate)
|
||||
model.MaxDate = mindate.AddYears (1).Date;
|
||||
|
||||
var muc = Membership.FindUsersByName (model.UserName);
|
||||
var muc = Membership.FindUsersByName (model.Person);
|
||||
if (muc.Count == 0) {
|
||||
ModelState.AddModelError ("UserName", "Non existent user");
|
||||
ModelState.AddModelError ("Person", LocalizedText.Non_existent_user);
|
||||
return View (model);
|
||||
}
|
||||
ProfileBase upr = ProfileBase.Create (model.UserName);
|
||||
if (!Roles.IsUserInRole (model.Role)) {
|
||||
ModelState.AddModelError ("Role", LocalizedText.UserNotInThisRole);
|
||||
return View (model);
|
||||
}
|
||||
|
||||
ProfileBase upr = ProfileBase.Create (model.Person);
|
||||
|
||||
string calid = (string)upr.GetPropertyValue ("gcalid");
|
||||
if (string.IsNullOrWhiteSpace (calid)) {
|
||||
ModelState.AddModelError ("UserName", "L'utilisateur n'a pas de calendrier Google associé.");
|
||||
ModelState.AddModelError ("Person", LocalizedText.No_calendar_for_this_user);
|
||||
return View (model);
|
||||
}
|
||||
|
||||
DateTime maxdate = model.MaxDate;
|
||||
|
||||
CalendarApi c = new CalendarApi ();
|
||||
CalendarEventList res;
|
||||
try {
|
||||
res = c.GetCalendar (calid, mindate, maxdate, upr);
|
||||
} catch (OtherWebException ex) {
|
||||
ViewData ["Title"] = ex.Title;
|
||||
ViewData ["Content"] = ex.Content;
|
||||
return View ("GoogleErrorMessage", ex);
|
||||
}
|
||||
var events = c.GetCalendar (calid, mindate, maxdate, upr);
|
||||
|
||||
return View ("ChooseADate",res);
|
||||
} catch (OtherWebException ex) {
|
||||
return View ("OtherWebException", ex);
|
||||
}
|
||||
}
|
||||
return View (model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,13 +22,15 @@
|
|||
|
||||
$(document).ready(function(){
|
||||
var $window = $(window);
|
||||
var onPos = function (bgobj,dx,dy) {
|
||||
x=$window.scrollLeft()+dx;
|
||||
y=$window.scrollTop()+dy;
|
||||
var $stwidth = $(window).width();
|
||||
var $stheight = $(window).width();
|
||||
|
||||
var onPos = function (bgobj,ax,ay) {
|
||||
var speed = bgobj.data('speed');
|
||||
var xPos = bgobj.attr('orgbgpx') - Math.round( x / speed);
|
||||
var yPos = bgobj.attr('orgbgpy') - Math.round( y / speed);
|
||||
var dx=($window.scrollLeft()+ax-$stwidth/2)/speed;
|
||||
var dy=($window.scrollTop()+ay-$stheight/2)/speed;
|
||||
var xPos = bgobj.attr('orgbgpx') - Math.round( dx );
|
||||
var yPos = bgobj.attr('orgbgpy') - Math.round( dy );
|
||||
// Put together our final background position
|
||||
var coords = '' + xPos + bgobj.attr('orgbgpxu') + yPos + bgobj.attr('orgbgpyu');
|
||||
// Move the background
|
||||
|
|
@ -80,18 +82,16 @@ $(document).ready(function(){
|
|||
});
|
||||
var nbevo=0;
|
||||
if (window.DeviceOrientationEvent) {
|
||||
if ($stwidth>320 && $stheight>320) {
|
||||
window.addEventListener('deviceorientation', function(event) {
|
||||
if (nbevo++>6) {
|
||||
tiltLR = event.gamma;
|
||||
titleFB = event.beta;
|
||||
tiltLR = $stwidth*Math.sin(event.gamma*Math.PI/180);
|
||||
titleFB = $stheight*Math.sin(event.beta*Math.PI/180);
|
||||
onPos($bgobj,tiltLR,titleFB);
|
||||
nbevo=0;
|
||||
}
|
||||
},false);
|
||||
},false); }
|
||||
$(window).mousemove(function(e) {
|
||||
tiltLR = e.pageX;
|
||||
titleFB = e.pageY;
|
||||
onPos($bgobj,tiltLR,titleFB);
|
||||
tiltLR = e.pageX;
|
||||
titleFB = e.pageY;
|
||||
onPos($bgobj,e.pageX,e.pageY);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue