changed redirect_to_current_compterendu view to use Maraude manager's

get_in_progress(), which is now a method instead of cache property.
+ better display of admin panel's buttons in sujets detail views
This commit is contained in:
artus40
2017-08-28 17:35:56 +02:00
parent 67a04f1c18
commit 0d3798f087
5 changed files with 24 additions and 24 deletions

View File

@@ -63,10 +63,9 @@ class MaraudeManager(Manager):
""" Dernière maraude """
return self.get_past().last()
@cached_property
def in_progress(self):
def get_in_progress(self):
""" Retourne la maraude en cours, ou None """
d, t = timezone.now().date(), timezone.now().time()
d, t = self.today, timezone.localtime(timezone.now()).time()
# Prendre le jour précédent s'il est entre minuit et 2h du matin
depassement = False
@@ -74,12 +73,16 @@ class MaraudeManager(Manager):
d = d - datetime.timedelta(days=1)
depassement = True
maraude_du_jour = self.get(date=d)
if maraude_du_jour:
try:
maraude_du_jour = self.get(date=d)
if depassement or t >= maraude_du_jour.heure_debut:
return maraude_du_jour
return None
else:
return None
except self.model.DoesNotExist:
return None

View File

@@ -98,14 +98,13 @@ class IndexView(NoteFormMixin, MaraudeurMixin, generic.TemplateView):
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 or
not prochaine_maraude.date == current_date):
maraude_en_cours = Maraude.objects.get_in_progress()
if not maraude_en_cours:
return redirect("maraudes:index")
kwargs = {'pk': prochaine_maraude.pk}
if not prochaine_maraude.est_terminee():
kwargs = {'pk': maraude_en_cours.pk}
if not maraude_en_cours.est_terminee():
return redirect("maraudes:create", **kwargs)
else:
return redirect("notes:details-maraude", **kwargs)