Skip to content

Commit

Permalink
Merge pull request #473 from jajodiaraghav/patch_4
Browse files Browse the repository at this point in the history
Add option to edit domains
  • Loading branch information
sid22 authored Aug 11, 2017
2 parents ec5fb02 + d22c399 commit f3b0562
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
19 changes: 13 additions & 6 deletions website/templates/issue.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
margin-top: 10px;
}
input[name="description"] {
width: 700px !important;
width: 600px !important;
}
{% endblock %}
{% block content %}
Expand All @@ -81,8 +81,10 @@ <h3 class="page-header">
</span>
<div class="form form-inline" style="display: none;">
{% csrf_token %}
<input type="text" name="description" class="form-control" value="" required>
<input type="text" name="domain" placeholder="Domain" class="form-control" value="" required>
<input type="text" name="description" placeholder="Bug Description" class="form-control" value="" required>
<select name="label" class="form-control" required>
<option value="0">General</option>
<option value="1">Number error</option>
<option value="2">Functional</option>
<option value="3">Performance</option>
Expand All @@ -95,7 +97,7 @@ <h3 class="page-header">
</div>
</h3>
<strong>Domain:</strong>
<a href="{{object.url}}" target="_new">{{object.url}}</a>
<a href="{{object.url}}" target="_new" class="issue-domain">{{object.url}}</a>
<div class="pull-right">
<a class="twitter-share-button btn btn-info"
href="https://twitter.com/intent/tweet?text=Bug on @{{object.domain_title}} - {{object.description}}"
Expand Down Expand Up @@ -196,7 +198,7 @@ <h4>OS Version: {{os_version}}</h4>
<div class="col-xs-6">
<div class="bug-info">
<strong>Bug Type:</strong>
<span class="label label-info">{{object.get_label_display}}</span>
<span class="label label-info bug-label">{{object.get_label_display}}</span>
</div>
<div class="bug-info">
<strong>Status:</strong>
Expand All @@ -206,7 +208,7 @@ <h4>OS Version: {{os_version}}</h4>
{% endif %}
</div>
<div class="bug-info">
<strong>Created on:</strong>
<strong>Added on:</strong>
<span class="label label-info">{{object.created}}</span>
</div>
</div>
Expand Down Expand Up @@ -270,6 +272,7 @@ <h3>Comments:</h3>
var label = {{object.label}};
$(document).on('click','.edit-issue',function(e){
$('.form input[name=description]').val($('.issue-desc').text());
$('.form input[name=domain]').val($('.issue-domain').text());
$('.form select').val(label);
$('.editables').hide();
$('.form').show();
Expand All @@ -287,18 +290,22 @@ <h3>Comments:</h3>
url: '/issue/edit/',
data:{
issue_pk: $('#issue_pk').val(),
domain: $('.form input[name=domain]').val(),
description: $('.form input[name=description]').val(),
label: $('.form select').val(),
csrfmiddlewaretoken: $('.form input[name=csrfmiddlewaretoken]').val(),
},
success: function(data){
$('.issue-desc').text($('.form input[name=description]').val());
$('.issue-domain').text($('.form input[name=domain]').val());
label = $('.form select').val();
var l = $(".form select option[value='"+label+"']").text();
$('.bug-info .label-info').text(l);
$('.bug-label').text(l);
$('.form').hide();
$('.editables').show();
$.notify("Issue updated!", {style: "custom", className: "success"});
if (data === "Domain Created")
$.notify("Domain Added!", {style: "custom", className: "success"});
},
error: function() {
$.notify("Some error occurred!", {style: "custom", className: "danger"});
Expand Down
10 changes: 9 additions & 1 deletion website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,19 @@ def get_context_data(self, **kwargs):
def IssueEdit(request):
if request.method == "POST":
issue = Issue.objects.get(pk=request.POST.get('issue_pk'))
uri = request.POST.get('domain')
link = uri.replace("www.", "")
if request.user == issue.user or request.user.is_superuser:
domain, created = Domain.objects.get_or_create(name=link, defaults={'url': "http://" + link})
issue.domain = domain
issue.url = uri
issue.description = request.POST.get('description')
issue.label = request.POST.get('label')
issue.save()
return HttpResponse("Updated")
if created:
return HttpResponse("Domain Created")
else:
return HttpResponse("Updated")
else:
return HttpResponse("Unauthorised")

Expand Down

0 comments on commit f3b0562

Please sign in to comment.