Created redirection view to make "Maraudes>Compte-rendu" link working everywhere
This commit is contained in:
@@ -6,22 +6,12 @@
|
|||||||
Tableau de bord
|
Tableau de bord
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation" {% active namespace="maraudes" viewname="create" %}
|
<li role="presentation" {% active namespace="maraudes" viewname="create" %}>
|
||||||
{% if not prochaine_maraude.date == date %} class="disabled">
|
<a href="{% url "maraudes:cr-link" %}">
|
||||||
<a href="#">
|
|
||||||
<span class="glyphicon glyphicon-pencil"></span>
|
<span class="glyphicon glyphicon-pencil"></span>
|
||||||
Compte-rendu
|
Compte-rendu
|
||||||
</a>
|
</a>
|
||||||
</li> {% else %}>
|
</li>
|
||||||
<a href="{% if prochaine_maraude.est_terminee %}
|
|
||||||
{% url 'notes:details-maraude' pk=prochaine_maraude.pk %}
|
|
||||||
{%else%}
|
|
||||||
{% url 'maraudes:create' pk=prochaine_maraude.pk %}
|
|
||||||
{% endif %}">
|
|
||||||
<span class="glyphicon glyphicon-pencil"></span>
|
|
||||||
Compte-rendu
|
|
||||||
</a>
|
|
||||||
</li> {% endif %}
|
|
||||||
<li role="presentation" {% active namespace="maraudes" viewname="planning" %}>
|
<li role="presentation" {% active namespace="maraudes" viewname="planning" %}>
|
||||||
<a href="{% url "maraudes:planning" %}">
|
<a href="{% url "maraudes:planning" %}">
|
||||||
<span class="glyphicon glyphicon-calendar"></span>
|
<span class="glyphicon glyphicon-calendar"></span>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.IndexView.as_view(), name="index"),
|
url(r'^$', views.IndexView.as_view(), name="index"),
|
||||||
|
url(r'^compte-rendu$', views.redirect_to_current_compterendu, name="cr-link"),
|
||||||
url(r'^planning/$', views.PlanningView.as_view(), name="planning"),
|
url(r'^planning/$', views.PlanningView.as_view(), name="planning"),
|
||||||
url(r'^lieu/create/$', views.LieuCreateView.as_view(), name="lieu-create"),
|
url(r'^lieu/create/$', views.LieuCreateView.as_view(), name="lieu-create"),
|
||||||
url(r'^(?P<pk>[0-9]+)/create/$', views.CompteRenduCreateView.as_view(), name="create"),
|
url(r'^(?P<pk>[0-9]+)/create/$', views.CompteRenduCreateView.as_view(), name="create"),
|
||||||
|
|||||||
@@ -67,8 +67,22 @@ class IndexView(NoteFormMixin, MaraudeurMixin, generic.TemplateView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## COMPTE-RENDU DE MARAUDE
|
## COMPTE-RENDU DE MARAUDE
|
||||||
|
|
||||||
|
|
||||||
|
def redirect_to_current_compterendu(request):
|
||||||
|
prochaine_maraude = Maraude.objects.get_next_of(request.user)
|
||||||
|
current_date = timezone.localtime(timezone.now()).date()
|
||||||
|
if not prochaine_maraude.date == current_date:
|
||||||
|
return redirect("maraudes:index")
|
||||||
|
|
||||||
|
kwargs = {'pk': prochaine_maraude.pk}
|
||||||
|
if not prochaine_maraude.est_terminee():
|
||||||
|
return redirect("maraudes:create", **kwargs)
|
||||||
|
else:
|
||||||
|
return redirect("notes:details-maraude", **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class CompteRenduCreateView(MaraudeurMixin, generic.DetailView):
|
class CompteRenduCreateView(MaraudeurMixin, generic.DetailView):
|
||||||
""" Vue pour la création d'un compte-rendu de maraude """
|
""" Vue pour la création d'un compte-rendu de maraude """
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user