Add edit button to info items on the info page.

This commit is contained in:
Víðir Valberg Guðmundsson 2018-05-06 13:22:04 +02:00
parent 025a5f76b7
commit e662064319
4 changed files with 13 additions and 3 deletions

View file

@ -54,7 +54,14 @@ Info | {{ block.super }}
<a href="#{{ item.anchor }}">
<i class="glyphicon glyphicon-link"></i>
</a>
{% if request.user in category.team.responsible_members.all %}
<a href="{% url 'teams:info_item_update' camp_slug=camp.slug team_slug=category.team.slug category_anchor=category.anchor item_anchor=item.anchor %}?next={% url 'info' camp_slug=camp.slug %}#{{ item.anchor }}"
class="btn btn-xs btn-primary pull-right">
<i class="fa fa-edit"></i> Edit
</a>
{% endif %}
</h4>
<small></small>
</div>
<div class="panel-body">
<p>{{ item.body|commonmark }}</p>

View file

@ -159,7 +159,7 @@ Team: {{ team.name }} | {{ block.super }}
<td>
<a href="{% url 'teams:info_item_update' camp_slug=camp.slug team_slug=team.slug category_anchor=info_category.anchor item_anchor=item.anchor %}"
class="btn btn-primary btn-sm">
<i class="fa fa-edit"></i> Edit Task
<i class="fa fa-edit"></i> Edit
</a>
</td>
</tr>

View file

@ -92,7 +92,7 @@ urlpatterns = [
]),
),
url(
r'^info_items/(?P<category_anchor>[-_\w+]+)/', include([
r'^info/(?P<category_anchor>[-_\w+]+)/', include([
url(
r'^create/$',
InfoItemCreateView.as_view(),

View file

@ -35,7 +35,7 @@ class InfoItemUpdateView(LoginRequiredMixin, CampViewMixin, EnsureTeamResponsibl
template_name = "info_item_form.html"
fields = ['headline', 'body', 'anchor', 'weight']
slug_field = 'anchor'
slug_url_kwarg = 'anchor'
slug_url_kwarg = 'item_anchor'
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
@ -43,4 +43,7 @@ class InfoItemUpdateView(LoginRequiredMixin, CampViewMixin, EnsureTeamResponsibl
return context
def get_success_url(self):
next = self.request.GET.get('next')
if next:
return next
return self.team.get_absolute_url()