Show global TermsAndConditions changed banner if member is logged in and has no date at which they accepted the terms of service

This commit is contained in:
Sebastiaan Janssen
2016-09-01 09:05:20 +02:00
parent 67d48acbf6
commit 088ce651c8
6 changed files with 68 additions and 0 deletions
+1
View File
@@ -1755,6 +1755,7 @@
<Content Include="masterpages\ProjectPage.master" />
<Content Include="umbraco\lib\bootstrap-tabdrop\README.md" />
<Content Include="Views\MacroPartials\Releases\ReleasesDropdown.cshtml" />
<Content Include="Views\Partials\Community\TermsAndConditions.cshtml" />
<None Include="Views\Partials\Forum\MemberBadge.cshtml" />
<Content Include="Views\Search\Search.aspx" />
<Content Include="Views\Web.config" />
@@ -12,6 +12,8 @@
}
}
@Html.Action("RenderTerms", "TermsAndConditions")
@* We'll show it differently on the homepage *@
@if (showNotification && Model.Content.Id != home.Id)
{
@@ -0,0 +1,13 @@
@using OurUmbraco.Our.Controllers
@model OurUmbraco.Our.Models.TermsAndConditionsModel
@if (Model.ShowTermsAndConditionsBanner)
{
<div class="alertbar__blue">
Hi! Our <a href="/terms-and-conditions">terms and conditions</a> for Our Umbraco have changed. <a href="/terms-and-conditions">Give them a read (we promise they're short)</a>.<br />
Your continued use of this site after changes are posted constitutes your acceptance of the terms and conditions as modified.<br />
@using (Html.BeginUmbracoForm<TermsAndConditionsController>("AcceptTerms"))
{
<input type="submit" value="Okay, noted. Close this notification." style="margin: 4px 0;"/>
}
</div>
}
@@ -0,0 +1,43 @@
using System;
using System.Web.Mvc;
using OurUmbraco.Our.Models;
using Umbraco.Web;
using Umbraco.Web.Mvc;
namespace OurUmbraco.Our.Controllers
{
public class TermsAndConditionsController : SurfaceController
{
[ChildActionOnly]
public ActionResult RenderTerms()
{
var model = new TermsAndConditionsModel();
var currentMember = Members.GetCurrentMember();
if (currentMember != null)
{
var tosAccepted = currentMember.GetPropertyValue<DateTime>("tos");
var newTosDate = new DateTime(2016, 09, 01);
if ((newTosDate - tosAccepted).TotalDays > 1)
{
model.ShowTermsAndConditionsBanner = true;
}
}
return PartialView("~/Views/Partials/Community/TermsAndConditions.cshtml", model);
}
public ActionResult AcceptTerms()
{
var currentMember = Members.GetCurrentMember();
if (currentMember != null)
{
var memberService = Services.MemberService;
var member = memberService.GetById(currentMember.Id);
member.SetValue("tos", DateTime.Now);
memberService.Save(member);
}
return RedirectToCurrentUmbracoPage();
}
}
}
@@ -0,0 +1,7 @@
namespace OurUmbraco.Our.Models
{
public class TermsAndConditionsModel
{
public bool ShowTermsAndConditionsBanner { get; set; }
}
}
+2
View File
@@ -415,6 +415,7 @@
<Compile Include="Our\Controllers\ProfileNotificationController.cs" />
<Compile Include="Our\Controllers\ProjectController.cs" />
<Compile Include="Our\Controllers\RegisterController.cs" />
<Compile Include="Our\Controllers\TermsAndConditionsController.cs" />
<Compile Include="Our\CustomHandlers\CommentVote.cs" />
<Compile Include="Our\CustomHandlers\ExternalVote.cs" />
<Compile Include="Our\CustomHandlers\ForumIndexer.cs" />
@@ -453,6 +454,7 @@
<Compile Include="Our\Models\RegisterModel.cs" />
<Compile Include="Our\Models\SearchResultContentModel.cs" />
<Compile Include="Our\Models\SearchResultModel.cs" />
<Compile Include="Our\Models\TermsAndConditionsModel.cs" />
<Compile Include="Our\ProjectFileUploadHandler.cs" />
<Compile Include="Our\Rest.cs" />
<Compile Include="Our\Scheduling\Scheduler.cs" />