Пример #1
0
    def save(self, *args, **kwargs):
        agora = super(CreateAgoraForm, self).save(commit=False)
        agora.create_name(self.request.user)
        agora.creator = self.request.user
        agora.url = self.request.build_absolute_uri(reverse('agora-view',
            kwargs=dict(username=agora.creator.username, agoraname=agora.name)))

        election = Election()
        agora.save()
        election.agora = agora
        election.creator = self.request.user
        election.name = "delegation"
        # Delegation elections do not actually need an url
        election.url = "http://example.com/delegation/has/no/url/" + str(uuid.uuid4())
        election.description = election.short_description = "voting used for delegation"
        election.election_type = Agora.ELECTION_TYPES[1][0] # simple delegation
        election.uuid = str(uuid.uuid4())
        election.created_at_date = datetime.datetime.now()
        election.create_hash()
        election.save()
        agora.delegation_election = election
        agora.members.add(self.request.user)
        agora.admins.add(self.request.user)
        agora.save()
        return agora
Пример #2
0
def create_delegation_election(sender, instance, created, **kwargs):
    if not created:
        return

    from agora_site.agora_core.models import Election

    election = Election()
    election.agora = instance
    election.creator = instance.creator
    election.name = "delegation"
    # Delegation elections do not actually need an url
    election.url = "http://example.com/delegation/has/no/url/" + str(uuid.uuid4())
    election.description = election.short_description = "voting used for delegation"
    election.election_type = Agora.ELECTION_TYPES[1][0] # simple delegation
    election.uuid = str(uuid.uuid4())
    election.created_at_date = timezone.now()
    election.create_hash()
    election.save()

    instance.delegation_election = election
    instance.save()
Пример #3
0
def create_delegation_election(sender, instance, created, **kwargs):
    if not created:
        return

    from agora_site.agora_core.models import Election

    election = Election()
    election.agora = instance
    election.creator = instance.creator
    election.name = "delegation"
    # Delegation elections do not actually need an url
    election.url = "http://example.com/delegation/has/no/url/" + str(uuid.uuid4())
    election.description = election.short_description = "voting used for delegation"
    election.election_type = Agora.ELECTION_TYPES[1][0] # simple delegation
    election.uuid = str(uuid.uuid4())
    election.created_at_date = timezone.now()
    election.create_hash()
    election.save()

    instance.delegation_election = election
    instance.save()