mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 03:11:48 -05:00
disqualification
This commit is contained in:
parent
746cb59f56
commit
ba7bfaabc5
4 changed files with 74 additions and 0 deletions
|
@ -121,6 +121,41 @@ public ActionResult Downvote(string id)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RequiresAdmin]
|
||||||
|
public ActionResult Disqualify(string id)
|
||||||
|
{
|
||||||
|
var db = new ApplicationDbContext();
|
||||||
|
var c = db.ContestEntries.FirstOrDefault(x => x.Id == id);
|
||||||
|
if (c == null)
|
||||||
|
return new HttpStatusCodeResult(404);
|
||||||
|
var model = new DisqualifySubmissionViewModel();
|
||||||
|
model.Entry = id;
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RequiresAdmin]
|
||||||
|
[HttpPost]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public ActionResult Disqualify(DisqualifySubmissionViewModel model)
|
||||||
|
{
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return View(model);
|
||||||
|
var db = new ApplicationDbContext();
|
||||||
|
var e = db.ContestEntries.FirstOrDefault(x => x.Id == model.Entry);
|
||||||
|
if (e == null)
|
||||||
|
return new HttpStatusCodeResult(404);
|
||||||
|
e.Disqualified = true;
|
||||||
|
e.DisqualifiedBy = User.Identity.GetUserId();
|
||||||
|
e.DisqualifiedReason = model.Reason;
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
NotificationDaemon.NotifyUser(User.Identity.GetUserId(), e.AuthorId, "Submission disqualified.", $@"We have disqualified your contest submission ""{e.Name}"".
|
||||||
|
|
||||||
|
<strong>Reason:</strong> {e.DisqualifiedReason}");
|
||||||
|
|
||||||
|
return RedirectToAction("ViewSubmission", new { id = model.Entry });
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult RemoveVote(string id)
|
public ActionResult RemoveVote(string id)
|
||||||
{
|
{
|
||||||
string uid = User.Identity.GetUserId();
|
string uid = User.Identity.GetUserId();
|
||||||
|
|
|
@ -65,6 +65,14 @@ public ContestEntry[] Entries
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DisqualifySubmissionViewModel
|
||||||
|
{
|
||||||
|
public string Entry { get; set; }
|
||||||
|
|
||||||
|
[Required(AllowEmptyStrings =false, ErrorMessage ="You must provide a reason.")]
|
||||||
|
public string Reason { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class ContestEntry
|
public class ContestEntry
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
|
@ -974,6 +974,7 @@
|
||||||
<Content Include="Views\Contests\CreateContest.cshtml" />
|
<Content Include="Views\Contests\CreateContest.cshtml" />
|
||||||
<Content Include="Views\Contests\SubmitEntry.cshtml" />
|
<Content Include="Views\Contests\SubmitEntry.cshtml" />
|
||||||
<Content Include="Views\Contests\ViewSubmission.cshtml" />
|
<Content Include="Views\Contests\ViewSubmission.cshtml" />
|
||||||
|
<Content Include="Views\Contests\Disqualify.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
|
30
Project-Unite/Views/Contests/Disqualify.cshtml
Normal file
30
Project-Unite/Views/Contests/Disqualify.cshtml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
@model Project_Unite.Models.DisqualifySubmissionViewModel
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Disqualify contest submission";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h2>Disqualify contest submission</h2>
|
||||||
|
|
||||||
|
<p>Are you sure you want to disqualify this entry?</p>
|
||||||
|
|
||||||
|
<div class="panel panel-warning">
|
||||||
|
<div class="panel-body">
|
||||||
|
<p><strong>Warning!</strong><br/>You cannot reverse this. Once the entry is disqualified, there's no re-qualifying it.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@using (Html.BeginForm())
|
||||||
|
{
|
||||||
|
@Html.ValidationSummary()
|
||||||
|
@Html.AntiForgeryToken()
|
||||||
|
@Html.HiddenFor(Model=>Model.Entry)
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>Disqualification reason:</dt>
|
||||||
|
<dd>Why did you disqualify this submission? @Html.TextBoxFor(Model=>Model.Reason, new { @class = "form-control" })</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<input type="submit" value="Disqualify" class="btn btn-default" />
|
||||||
|
<a href="#" onclick="window.history.back()" class="btn btn-default">Go back</a>
|
||||||
|
}
|
Loading…
Reference in a new issue