Example #1
0
    def post(self):
        job = models.ProcessingJob.get(self.request.get('job_key'))

        try:
            description = "Sends the list of voters for CS Club elections"
            # Assertion here to ensure that the developer is running the right
            # task
            assert(job.description == description)

            ### Processing begin ###

            csclub = models.get_organization("Rice CS Club")
            election = models.Election.gql("WHERE name=:1 AND organization=:2", 
                "General Elections 2014-2015", csclub).get()
            admin_emails = [o.admin.email for o in election.organization.organization_admins]
            message = mail.EmailMessage(sender="*****@*****.**", subject="Voter Report for %s" % election.name)
            message.to = ', '.join(admin_emails)
            message.body = '\n'.join(["NetID: %s    Vote Time (UTC): %s" % (ev.voter.net_id, ev.vote_time) for ev in election.election_voters])
            message.send()

            ### Processing end ###

            job.status = "complete"
        finally:
            if job.status != "complete":
                job.status = "failed"
            job.ended = datetime.datetime.now()
            job.put()
Example #2
0
 def add_admin(self, data):
     org = models.get_organization(data['organization'])
     voter = models.get_voter(data['net_id'], create=True)
     org_admin = models.put_admin(voter, data['net_id']+'@rice.edu', org)
     if org_admin:
         webapputils.respond(self, 'OK', 'Done')
     else:
         webapputils.respond(self, 'ERROR', "Couldn't create admin")
Example #3
0
 def add_admin(self, data):
     org = models.get_organization(data['organization'])
     voter = models.get_voter(data['net_id'], create=True)
     org_admin = models.put_admin(voter, data['net_id'] + '@rice.edu', org)
     if org_admin:
         webapputils.respond(self, 'OK', 'Done')
     else:
         webapputils.respond(self, 'ERROR', "Couldn't create admin")
Example #4
0
    def post(self):
        job = models.ProcessingJob.get(self.request.get('job_key'))

        try:
            description = "Sends the list of voters for CS Club elections"
            # Assertion here to ensure that the developer is running the right
            # task
            assert (job.description == description)

            ### Processing begin ###

            csclub = models.get_organization("Rice CS Club")
            election = models.Election.gql("WHERE name=:1 AND organization=:2",
                                           "General Elections 2014-2015",
                                           csclub).get()
            admin_emails = [
                o.admin.email
                for o in election.organization.organization_admins
            ]
            message = mail.EmailMessage(
                sender="*****@*****.**",
                subject="Voter Report for %s" % election.name)
            message.to = ', '.join(admin_emails)
            message.body = '\n'.join([
                "NetID: %s    Vote Time (UTC): %s" %
                (ev.voter.net_id, ev.vote_time)
                for ev in election.election_voters
            ])
            message.send()

            ### Processing end ###

            job.status = "complete"
        finally:
            if job.status != "complete":
                job.status = "failed"
            job.ended = datetime.datetime.now()
            job.put()
Example #5
0
    def post(self):
        job = models.ProcessingJob.get(self.request.get('job_key'))

        try:
            description = "Deletes Campus Wide Positions Election for Martel Its Incomplete"
            # Assertion here to ensure that the developer is running the right
            # task
            assert(job.description == description)

            ### Processing begin ###

            martel = models.get_organization("Martel College")
            campus_wide = models.Election.gql("WHERE name=:1 AND organization=:2",
                "Campus Wide Positions", martel).get()
            models.delete_election(campus_wide)

            ### Processing end ###

            job.status = "complete"
        finally:
            if job.status != "complete":
                job.status = "failed"
            job.ended = datetime.datetime.now()
            job.put()