Skip to content

Commit

Permalink
added update meta functionality #14
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroq committed May 5, 2019
1 parent 74c4102 commit dfc61c7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h3 class="panel-title">{{ incident.title }}<i id="toggle-commentsidebar" class=
</select>
</li>
<li>Description</li>
<li><textarea class="form-control" name="package_description" rows="13">{{ incident.description }}</textarea></li>
<li><textarea class="form-control" name="incident_description" rows="13">{{ incident.description }}</textarea></li>
<li><button type="submit" class="btn btn-primary close-navsidebar">Submit</button></li>
</ul>
</form>
Expand Down
21 changes: 20 additions & 1 deletion kraut_incident/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,26 @@ def update_incident_header(request, incident_id):
"""Update incident header information
"""
context = {}
return render(request, 'kraut_incident/incident_list.html', context)
try:
inc = Incident.objects.get(id=incident_id)
except Incident.DoesNotExist:
messages.error(request, 'The requested incident does not exist!')
return render(request, 'kraut_incident/incident_list.html', context)
if request.method == "POST":
inc_title = request.POST.get('incident_title', None)
inc_severity = request.POST.get('incident_severity', None)
inc_descr = request.POST.get('incident_description', None)
if inc_title:
inc.title = inc_title
if inc_severity:
if inc_severity == 'High': inc_severity = 'h'
if inc_severity == 'Medium': inc_severity = 'm'
if inc_severity == 'Low': inc_severity = 'l'
inc.severity = inc_severity
if inc_descr:
inc.description = inc_descr
inc.save()
return HttpResponseRedirect(reverse("incidents:view_incident", kwargs={'incident_id': incident_id}))

@login_required
def comment_incident(request, incident_id):
Expand Down

0 comments on commit dfc61c7

Please sign in to comment.