Many changes :

* JsonReaderError.aspx: display a nice json conversion error

* CalendarEntryList.cs: new Google data for the calendar entries

* JsonReaderError.cs: Json error model

* README.md: Documentation url

* NpgsqlBlogProvider.cs: Update the blog post title

* BlogsController.cs: - Updating the blog post title
- bug fix rendering the avatar

* FrontOfficeController.cs: - the client cannot modify its estimation

* GoogleController.cs: - implementing the calendar entries retrieval

* HomeController.cs: - the home start page from configuration
  parameter named "StartPage"

* Global.asax.cs: - back to a clean global.asax

* style.css: showing the main area with a background transparent color

* Post.aspx: Bug fix: the message was displayed two times (we keep the
  one from app.master)

* UserPost.aspx: the blog title comes from the poster profile found in
  ViewData

* DateQuery.aspx: implementing the date query

* Web.config: the start page now comes from Web.config

* Web.csproj: the Sql db creation script should not be deployed,
  neither as package.config

* BlogManager.cs: updating the blog post title

* BlogProvider.cs: yavscModel/Blogs/BlogManager.cs


* YavscModel.csproj: new cs files to compile

* App.master: returning from the Google login
This commit is contained in:
Paul Schneider 2015-01-06 10:15:24 +01:00
commit 57a473aff8
20 changed files with 163 additions and 57 deletions

View file

@ -122,6 +122,7 @@ namespace Yavsc.Controllers
return View ("TitleNotFound");
ViewData ["BlogUserProfile"] = pr;
ViewData ["BlogTitle"] = pr.BlogTitle;
ViewData ["HasAvatar"] = pr.avatar != null;
MembershipUser u = Membership.GetUser ();
if (u != null)
ViewData ["UserName"] = u.UserName;
@ -159,8 +160,6 @@ namespace Yavsc.Controllers
string un = Membership.GetUser ().UserName;
if (String.IsNullOrEmpty (user))
user = un;
if (un != user)
ViewData ["Message"] = string.Format ("Vous n'êtes pas {0}!", user);
ViewData ["UserName"] = un;
return View (new BlogEditEntryModel { Title = title });
}
@ -187,7 +186,7 @@ namespace Yavsc.Controllers
ViewData ["BlogUser"] = Membership.GetUser ().UserName;
if (ModelState.IsValid) {
if (!model.Preview) {
BlogManager.UpdatePost (model.Id, model.Content, model.Visible);
BlogManager.UpdatePost (model.Id, model.Title, model.Content, model.Visible);
return UserPost (model);
}
}
@ -247,11 +246,9 @@ namespace Yavsc.Controllers
return File (fia.OpenRead (), defaultAvatarMimetype);
}
WebRequest wr = WebRequest.Create(avpath);
using (WebResponse resp = wr.GetResponse ()) {
using (Stream str = resp.GetResponseStream ()) {
return File (str, resp.ContentType);
}
}
WebResponse resp = wr.GetResponse ();
Stream str = resp.GetResponseStream ();
return File (str, resp.ContentType);
}
/// <summary>

View file

@ -71,7 +71,6 @@ namespace Yavsc.Controllers
}
if (ModelState.IsValid) {
if (username != model.Responsible
&& username != model.Client
&& !Roles.IsUserInRole ("FrontOffice"))
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");

View file

@ -26,22 +26,22 @@ namespace Yavsc.Controllers
// 2015-01-01T10:00:00-07:00
// private string API_KEY="AIzaSyBV_LQHb22nGgjNvFzZwnQHjao3Q7IewRw";
private string getPeopleUri = "https://www.googleapis.com/plus/v1/people";
private string getCalListUri = "https://www.googleapis.com/calendar/v3/users/me/calendarList";
private string getCalEntriesUri = "https://developers.google.com/google-apps/calendar/v3/reference/events/list";
private static string getPeopleUri = "https://www.googleapis.com/plus/v1/people";
private static string getCalListUri = "https://www.googleapis.com/calendar/v3/users/me/calendarList";
private static string getCalEntriesUri = "https://www.googleapis.com/calendar/v3/calendars/{0}/events";
private string CLIENT_ID = "325408689282-6bekh7p3guj4k0f3301a6frf025cnrk1.apps.googleusercontent.com";
private string CLIENT_SECRET = "MaxYcvJJCs2gDGvaELZbzwfL";
private static string CLIENT_ID = "325408689282-6bekh7p3guj4k0f3301a6frf025cnrk1.apps.googleusercontent.com";
private static string CLIENT_SECRET = "MaxYcvJJCs2gDGvaELZbzwfL";
string[] SCOPES = {
private static string[] SCOPES = {
"openid",
"profile",
"email"
};
string tokenUri = "https://accounts.google.com/o/oauth2/token";
string authUri = "https://accounts.google.com/o/oauth2/auth";
private static string tokenUri = "https://accounts.google.com/o/oauth2/token";
private static string authUri = "https://accounts.google.com/o/oauth2/auth";
private static string dateFormat = "yyyy-MM-dd'T'HH:mm:ss.fffK";
private string SetSessionSate ()
{
Random rand = new Random ();
@ -363,14 +363,24 @@ namespace Yavsc.Controllers
ModelState.AddModelError ("MinTime", "This first date must be lower than the second one.");
return View (model);
}
ProfileBase upr = ProfileBase.Create (model.UserName);
if (upr == null) {
var muc = Membership.FindUsersByName (model.UserName);
if (muc.Count==0) {
ModelState.AddModelError ("UserName", "Non existent user");
return View (model);
}
ProfileBase upr = ProfileBase.Create (model.UserName);
HttpWebRequest webreq = WebRequest.CreateHttp (getCalEntriesUri);
string calid = (string) upr.GetPropertyValue ("gcalid");
if (string.IsNullOrWhiteSpace(calid)) {
ModelState.AddModelError ("UserName", "L'utilisateur n'a pas de calendrier Google associé.");
return View (model);
}
HttpWebRequest webreq = WebRequest.CreateHttp (
string.Format(
getCalEntriesUri, calid)+
string.Format("?singleEvents=true&orderBy=startTime&timeMin={0}&timeMax={1}",
model.MinDate.ToString(dateFormat),model.MaxDate.ToString(dateFormat))
);
webreq.Headers.Add (HttpRequestHeader.Authorization, GetFreshGoogleCredential(upr));
webreq.Method = "GET";
webreq.ContentType = "application/http";
@ -378,12 +388,18 @@ namespace Yavsc.Controllers
using (Stream respstream = resp.GetResponseStream ()) {
using (StreamReader readresp = new StreamReader (respstream, Encoding.UTF8)) {
string responseStr = readresp.ReadToEnd ();
CalendarList res = JsonConvert.DeserializeObject<CalendarList> (responseStr);
try {
CalendarEntryList res = JsonConvert.DeserializeObject<CalendarEntryList> (responseStr);
ViewData ["json"] = responseStr;
return View (res);
}
catch (JsonReaderException ex) {
return View ("JsonReaderError", new JsonReaderError() {Text= responseStr, Excepx = ex});
}
}
}
}
}
return View (model);
}

View file

@ -69,7 +69,9 @@ namespace Yavsc.Controllers
public ActionResult Index ()
{
string cn = CultureInfo.CurrentCulture.Name;
string startPage = WebConfigurationManager.AppSettings ["StartPage"];
if (startPage != null)
Redirect (startPage);
ViewData ["Message"] = LocalizedText.Welcome;
return View ();
}