QSO deleting is now beautiful!

This commit is contained in:
Sebastian Lohff 2017-01-21 01:08:40 +01:00
parent 8d716f1a8b
commit 80934bda32
3 changed files with 24 additions and 16 deletions

View File

@ -62,3 +62,6 @@ class QSO(models.Model):
ref = models.ForeignKey(Reference, null=True, blank=True) ref = models.ForeignKey(Reference, null=True, blank=True)
remarks = models.CharField(max_length=50, blank=True) remarks = models.CharField(max_length=50, blank=True)
def __str__(self):
return "QSO no %s at %s with %s@%s %s/%s" % (self.ownNo, self.time.strftime("%H:%M"), self.call, self.refStr, self.reportTX, self.reportRX)

View File

@ -88,11 +88,11 @@ def logDelete(request, qsoid):
if request.method == 'POST': if request.method == 'POST':
if "delete" in request.POST: if "delete" in request.POST:
if request.POST["delete"] == "yes": if request.POST["delete"].lower() == "yes":
qso.delete() qso.delete()
messages.info(request, "QSO has been deleted") messages.info(request, "QSO has been deleted")
return HttpResponseRedirect(reverse("contest:log")) return HttpResponseRedirect(reverse("contest:log"))
elif request.POST["delete"] == "no": elif request.POST["delete"].lower() == "no":
return HttpResponseRedirect(reverse("contest:log")) return HttpResponseRedirect(reverse("contest:log"))
return render(request, 'contest/logDelete.html', {"qso": qso}) return render(request, 'contest/logDelete.html', {"qso": qso})

View File

@ -3,20 +3,25 @@
{% block content %} {% block content %}
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
We have the User {{ user }}, create a ref for them or choose an existing ref! <div class="panel panel-default">
<div class="panel-heading">Delete QSO</div>
Are you sure you want to delete this QSO? <div class="panel-body">
<form method="post" action="{% url "contest:logDelete" qso.id %}"> <p>
{% csrf_token %} Are you sure you want to delete this QSO?
<table> </p>
<tr> <form method="post" action="{% url "contest:logDelete" qso.id %}">
<th>QSO</th><td>{{ qso }}</td> {% csrf_token %}
</tr> <div class="form-group">
</table> <label for="id-qso-name" class="control-label">QSO</label>
<input type="submit" name="delete" value="yes"> <div id="id-qso-name" class="controls readonly">{{ qso }}</div>
<input type="submit" name="delete" value="no"> </div>
<div class="btn-group">
</form> <input type="submit" name="delete" class="btn btn-danger" value="Yes">
<input type="submit" name="delete" class="btn btn-default" value="No">
</div>
</form>
</div>
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}