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