You can now post bugs.

Well, there's no categories to post them in, yet.
This commit is contained in:
Michael 2017-04-14 17:54:26 -04:00
parent e63b7b343b
commit a2cbddfbfd
3 changed files with 141 additions and 0 deletions

View file

@ -56,5 +56,79 @@ public ActionResult ViewBug(ViewBugViewModel model)
model.Comment = "";
return View(model);
}
[Authorize]
public ActionResult OpenBug(string id)
{
var db = new ApplicationDbContext();
var bug = db.Bugs.FirstOrDefault(x => x.Id == id);
if (bug == null)
return new HttpStatusCodeResult(404);
bug.Open = true;
db.SaveChanges();
return RedirectToAction("ViewCategory", new { id = bug.Species });
}
[Authorize]
public ActionResult CloseBug(string id)
{
var db = new ApplicationDbContext();
var bug = db.Bugs.FirstOrDefault(x => x.Id == id);
if (bug == null)
return new HttpStatusCodeResult(404);
bug.Open = false;
bug.ClosedAt = DateTime.Now;
bug.ClosedBy = User.Identity.GetUserId();
db.SaveChanges();
return RedirectToAction("ViewCategory", new { id = bug.Species });
}
[Authorize]
public ActionResult PostBug()
{
var model = new PostBugViewModel();
return View(model);
}
[Authorize]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult PostBug(PostBugViewModel model)
{
if (!ModelState.IsValid)
return View(model);
var db = new ApplicationDbContext();
var bug = new Bug();
bug.Name = model.Name;
string allowed = "abcdefghijklmnopqrstuvwxyz1234567890_-";
string id = bug.Name.ToLower() + "_" + db.Bugs.Count().ToString();
foreach(var c in id.ToCharArray())
{
if (!allowed.Contains(c))
id = id.Replace(c, '_');
}
bug.Id = id;
bug.Open = true;
bug.Reporter = User.Identity.GetUserId();
bug.ReportedAt = DateTime.Now;
bug.Species = model.SpeciesId;
bug.Urgency = int.Parse(model.Urgency);
bug.ReleaseId = model.VersionId;
var comment = new ForumPost();
comment.AuthorId = User.Identity.GetUserId();
comment.Body = model.Description;
comment.Id = Guid.NewGuid().ToString();
comment.Parent = bug.Id;
comment.PostedAt = DateTime.Now;
db.ForumPosts.Add(comment);
db.Bugs.Add(bug);
db.SaveChanges();
return RedirectToAction("ViewBug", new { id = bug.Id });
}
}
}

View file

@ -566,6 +566,7 @@
<Content Include="Views\Bugs\_Sidebar.cshtml" />
<Content Include="Views\Bugs\ViewCategory.cshtml" />
<Content Include="Views\Bugs\ViewBug.cshtml" />
<Content Include="Views\Bugs\PostBug.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

View file

@ -0,0 +1,66 @@
@model Project_Unite.Models.PostBugViewModel
@{
ViewBag.Title = "Post a bug";
}
<h2>Post a bug</h2>
<p>Found a crash? Something inconsistent? Inconvenient? Whatever it is, we wanna know so we can fix it.</p>
<p>Just fill out this quick form.</p>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="panel panel-danger">
<div class="panel-default">
@Html.ValidationSummary()
</div>
</div>
<table class="table">
<tr>
<td style="width:25%;"><strong>Name:</strong></td>
<td>@Html.TextBoxFor(Model=>Model.Name, new { @class = "form-control" })</td>
</tr>
<tr>
<td><strong>Version:</strong><br/>
What version of ShiftOS did you experience this bug in?</td>
<td>@Html.DropDownListFor(Model=>Model.VersionId, Model.Versions, new{@class="form-control"})</td>
</tr>
<tr>
<td>
<strong>Urgency:</strong><br />
How bad of a bug is this?
</td>
<td>@Html.DropDownListFor(Model => Model.Urgency, Model.Urgencies, new { @class = "form-control" })</td>
</tr>
<tr>
<td>
<strong>Category:</strong><br />
What species of bug is this? (Hah, I'm tying biology into programming terms.)
</td>
<td>@Html.DropDownListFor(Model => Model.SpeciesId, Model.Species, new { @class = "form-control" })</td>
</tr>
<tr>
<td><strong>Details:</strong><br/>
Here you can supply as much detail as you want about the bug. Screenshots, links, explanations, crashes, logs, etc. The more info there is, the more we can help.<br/><br/>
<strong>Markdown formatting is supported.</strong></td>
<td>@Html.TextAreaFor(Model=>Model.Description, new { @class = "form-control", rows = "5" })</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit report" class="btn btn-primary"/></td>
</tr>
</table>
<h4>Note on Rolling Release Builds</h4>
<p>It's worth noting that rolling release builds follow the same bug support as the latest version of the standard-release ShiftOS. So, if you are running on the rolling release version, and the latest version is Beta 2, submit the bug for Beta 2.</p>
<h4>My version of the game is not showing!</h4>
<p>Note that obsolete versions of ShiftOS are not supported by us anymore, and thus, you may not submit a bug report for these versions.</p>
<p>Also, any forked versions of ShiftOS are not supported by us. It is up to the developers of the fork to maintain their releases, keep their codebase in sync with ours, and take care of bugs that we don't cover.</p>
}