Commit b3fca75b authored by maxime's avatar maxime

base active actions on enddate #419

parent 4a566670
......@@ -27,7 +27,7 @@ User._meta.rdf_context = {"get_full_name": "rdfs:label"}
User._meta.get_field('username').verbose_name = "Email"
def active_actions(self):
return self.actiongroups.filter(actiondate__gte=date.today())
return self.actiongroups.filter(endactiondate__gte=date.today())
User.active_actions=active_actions
......@@ -206,6 +206,9 @@ class ActionGroup(Model):
anytwittTargets = models.TextField(blank=True, null=True, verbose_name=u"Tweet Global - Targets")
anytwittExplination = models.TextField(blank=True, null=True, verbose_name=u"Tweet Global - Explination")
class Meta:
auto_author = 'author'
serializer_fields = ['@id','anytwittExplination','anytwittTargets','anytwittContent','videourl','videotitle','calltitle','callcontent','callmoreinfo','supported_group','twitter_content','name', 'related_text', 'author','pressreleasetitle','pressreleasecontent','jugementmaj','signuplink','instagram','twitter','facebook', 'objective','actiondate','endactiondate','actioninfolink', 'description', 'theme', 'frequency','linkcollabtext','electedofficialemailsubject', 'electedofficialemailtext', 'representatives', 'members', 'actiongroups', 'loomios', 'conversation', 'address', 'city', 'postcode', 'lat', 'lng', 'events','org_actions']
......@@ -216,17 +219,15 @@ class ActionGroup(Model):
owner_field = 'author'
ordering=['actiondate']
def __str__(self):
return self.name
#Check if end date informed, if not then set it as startdate
@receiver(post_save, sender=ActionGroup)
def save_endactiondate_actiongroup(sender, instance, created, **kwargs):
def save_actiongroup(sender, instance, created, **kwargs):
if created:
if ActionGroup.endactiondate == "null":
return ActionGroup.endactiondate == ActionGroup.actiondate
super().save(*args, **kwargs)
if not instance.endactiondate:
instance.endactiondate = instance.actiondate
super(ActionGroup, instance).save()
class TextSupporters_Email(Model):
......
......@@ -47,9 +47,10 @@ class RepresentativeViewSet(LDPViewSet):
class ActionViewSet(LDPViewSet):
model=ActionGroup
def get_queryset(self, *args, **kwargs):
return super().get_queryset(*args, **kwargs).exclude(actiondate__lt=date.today())
return super().get_queryset(*args, **kwargs).exclude(endactiondate__lt=date.today())
class OrganisationViewSet(LDPViewSet):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment