Move delete buttons to edit page
This commit is contained in:
parent
2d9ea3b311
commit
2a5bf7ad93
@ -95,6 +95,9 @@
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||
<input class="ui primary button" type="submit" name='submit' value="Save">
|
||||
<input class="ui button" type="submit" name='submit' value="Save and continue editing">
|
||||
{% if request.resolver_match.url_name == 'bulletin_edit' %}
|
||||
<input class="ui right floated red button" type="submit" name='submit' value="Delete" onclick="return confirm('Are you sure you want to delete this bulletin item? This action is IRREVERSIBLE.');">
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{#
|
||||
Society Self-Service
|
||||
Copyright © 2018 Yingtong Li (RunasSudo)
|
||||
Copyright © 2018-2019 Yingtong Li (RunasSudo)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -24,9 +24,9 @@
|
||||
<table class="ui selectable celled table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="four wide">Title</th>
|
||||
<th class="five wide">Title</th>
|
||||
<th class="ten wide">Content</th>
|
||||
<th class="two wide">Actions</th>
|
||||
<th class="one wide">Edit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -34,9 +34,8 @@
|
||||
<tr>
|
||||
<td class="selectable"><a href="{{ url('bulletin_edit', kwargs={'id': item.id}) }}">{{ item.title }}</a></td>
|
||||
<td>{{ item.content|markdown }}</td>
|
||||
<td class="selectable">
|
||||
<a href="{{ url('bulletin_edit', kwargs={'id': item.id}) }}" class="ui tiny primary icon button" style="margin: 0.8em 0 0.8em 0.8em;"><i class="edit icon"></i></a>
|
||||
<a href="{{ url('bulletin_delete', kwargs={'id': item.id}) }}" onclick="return confirm('Are you sure you want to delete this bulletin item?');" class="ui tiny red icon button" style="margin: 0.8em 0 0.8em 0.8em;"><i class="trash icon"></i></a>
|
||||
<td>
|
||||
<a href="{{ url('bulletin_edit', kwargs={'id': item.id}) }}" class="ui tiny primary icon button"><i class="edit icon"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -22,7 +22,6 @@ urlpatterns = [
|
||||
path('bulletin/', views.bulletin_list, name='bulletin_list'),
|
||||
path('bulletin/new/', views.bulletin_new, name='bulletin_new'),
|
||||
path('bulletin/edit/<int:id>', views.bulletin_edit, name='bulletin_edit'),
|
||||
path('bulletin/delete/<int:id>', views.bulletin_delete, name='bulletin_delete'),
|
||||
path('bulletin/preview/', views.bulletin_preview, name='bulletin_preview'),
|
||||
path('', views.index, name='promotions'),
|
||||
]
|
||||
|
@ -112,9 +112,20 @@ def bulletin_new(request):
|
||||
def bulletin_edit(request, id):
|
||||
if request.method == 'POST':
|
||||
item = models.BulletinItem.objects.get(id=id)
|
||||
|
||||
# Check access with old group
|
||||
if not item.can_user_access(request.user):
|
||||
return HttpResponse('Unauthorized', status=401)
|
||||
|
||||
if request.POST['submit'] == 'Delete':
|
||||
item.delete()
|
||||
return redirect(reverse('bulletin_list'))
|
||||
|
||||
# Check access with new group
|
||||
item.group = models.Group.objects.get(id=int(request.POST['group']))
|
||||
if not item.can_user_access(request.user):
|
||||
return HttpResponse('Unauthorized', status=401)
|
||||
|
||||
item.title = request.POST['title']
|
||||
item.date = request.POST['date']
|
||||
item.content = request.POST['content']
|
||||
@ -132,16 +143,8 @@ def bulletin_edit(request, id):
|
||||
item = models.BulletinItem.objects.get(id=id)
|
||||
if not item.can_user_access(request.user):
|
||||
return HttpResponse('Unauthorized', status=401)
|
||||
|
||||
return render(request, 'sspromotions/bulletin_edit.html', {
|
||||
'item': item,
|
||||
'groups': models.Group.objects.filter(hidden=False).all()
|
||||
})
|
||||
|
||||
@login_required
|
||||
def bulletin_delete(request, id):
|
||||
item = models.BulletinItem.objects.get(id=id)
|
||||
if not item.can_user_access(request.user):
|
||||
return HttpResponse('Unauthorized', status=401)
|
||||
item.delete()
|
||||
|
||||
return redirect(reverse('bulletin_list'))
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{#
|
||||
Society Self-Service
|
||||
Copyright © 2018 Yingtong Li (RunasSudo)
|
||||
Copyright © 2018-2019 Yingtong Li (RunasSudo)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -95,6 +95,9 @@
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||
<input class="ui primary button" type="submit" name='submit' value="Save">
|
||||
<input class="ui button" type="submit" name='submit' value="Save and continue editing">
|
||||
{% if request.resolver_match.url_name == 'budget_edit' %}
|
||||
<input class="ui right floated red button" type="submit" name='submit' value="Delete" onclick="return confirm('Are you sure you want to delete this budget? This action is IRREVERSIBLE.');">
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{#
|
||||
Society Self-Service
|
||||
Copyright © 2018 Yingtong Li (RunasSudo)
|
||||
Copyright © 2018-2019 Yingtong Li (RunasSudo)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -26,6 +26,7 @@
|
||||
<tr>
|
||||
<th class="twelve wide">Name</th>
|
||||
<th class="four wide">Status</th>
|
||||
<th class="one wide">View</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -33,6 +34,9 @@
|
||||
<tr>
|
||||
<td class="selectable"><a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}">{{ revision.name }}</a></td>
|
||||
<td class="selectable"><a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}">{{ import('sstreasury.models').BudgetState(revision.state).description }}</a></td>
|
||||
<td>
|
||||
<a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}" class="ui tiny primary icon button"><i class="eye icon"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@ -71,4 +75,4 @@
|
||||
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{#
|
||||
Society Self-Service
|
||||
Copyright © 2018 Yingtong Li (RunasSudo)
|
||||
Copyright © 2018-2019 Yingtong Li (RunasSudo)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Society Self-Service
|
||||
# Copyright © 2018 Yingtong Li (RunasSudo)
|
||||
# Copyright © 2018-2019 Yingtong Li (RunasSudo)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Society Self-Service
|
||||
Copyright © 2018 Yingtong Li (RunasSudo)
|
||||
Copyright © 2018-2019 Yingtong Li (RunasSudo)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Society Self-Service
|
||||
# Copyright © 2018 Yingtong Li (RunasSudo)
|
||||
# Copyright © 2018-2019 Yingtong Li (RunasSudo)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
@ -138,6 +138,10 @@ def budget_edit(request, id):
|
||||
if request.user not in revision.contributors.all():
|
||||
raise PermissionDenied
|
||||
|
||||
if request.POST['submit'] == 'Delete':
|
||||
budget.delete()
|
||||
return redirect(reverse('budget_list'))
|
||||
|
||||
with transaction.atomic():
|
||||
revision = models.BudgetRevision()
|
||||
revision.author = request.user
|
||||
|
Loading…
Reference in New Issue
Block a user