Skip to content

Commit

Permalink
Merge pull request #90 from taeseunglee/issue_85
Browse files Browse the repository at this point in the history
Issue 85
  • Loading branch information
juice500ml authored Mar 18, 2017
2 parents c2e0c78 + defe44b commit eed8838
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions coding_night_live/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def PageNotFound(request):

def withdraw(request):
if request.method == 'POST':
User.objects.get(email=request.user.email).delete
User.objects.get(email=request.user.email).delete()
else:
print('Request method is not a GET.')
return HttpResponseRedirect('/')
return HttpResponseRedirect('/')
35 changes: 33 additions & 2 deletions templates/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ <h4 class="modal-title">Are you sure to delete this room?</h4>
</div>
</div>

<!-- Account Withdraw modal -->
<div class="modal fade" id="account_withdraw_modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Are you sure you want to withdraw from your account?</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="withdrawAccount()">Withdrawal</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

<nav class="navbar navbar-light bg-faded" style="background-color:#0275d8; border-radius:0em;">
<a class="navbar-brand" href="#">
<img src="{% static "image/small-logo-point.png" %}" height="30vh">
Expand All @@ -61,6 +76,7 @@ <h4 class="modal-title">Are you sure to delete this room?</h4>
{% load account %}
<a class="nav-link dropdown-toggle" href="#" id="logged_dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color:white">Welcome, <b>{% user_display user %}</b></a>
<div class="dropdown-menu" aria-labelledby="logged_dropdown">
<a class="dropdown-item" href="#" onclick="withdrawAccountModal()">Withdraw</a>
<a class="dropdown-item" href="{% url 'logout' %}">Logout</a>
</div>
</li>
Expand All @@ -79,7 +95,7 @@ <h4 class="list-group-item-heading" align="center"><i class="fa fa-plus" aria-hi
<div class="list-group-item list-group-item-action">
<h4 class="list-group-item-heading"><a class="room-link-element" href="{{ room.link }}">{{ room.title }}</a></h4>
<span class="tag tag-danger tag-pill float-xs-right">
<a href="#" class="room-delete-element" onclick="deleteRoom('{% url 'delete' pk=room.label %}')">Delete</a>
<a href="#" class="room-delete-element" onclick="deleteRoomModal('{% url 'delete' pk=room.label %}')">Delete</a>
</span>
<p class="list-group-item-text">Generated at {{ room.time }}</p>
</div>
Expand All @@ -90,10 +106,25 @@ <h4 class="list-group-item-heading"><a class="room-link-element" href="{{ room.l
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>

<script>
function deleteRoom(link) {
function deleteRoomModal(link) {
$('#modal_delete_button').attr('onclick', 'location.href="' + link + '"');
$('#room_delete_modal').modal('show');
}

function withdrawAccountModal() {
$('#account_withdraw_modal').modal('show');
}

function withdrawAccount() {
$.ajax({
url: "{% url 'withdraw' %}",
type: "POST",
data: { csrfmiddlewaretoken: "{{ csrf_token }}", },
success: function() {
location.href="/";
}
});
}
</script>
</body>
</html>

0 comments on commit eed8838

Please sign in to comment.