コード例 #1
0
ファイル: intern.py プロジェクト: gwarr3n/rice-elections
    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()
コード例 #2
0
ファイル: intern.py プロジェクト: rice-apps/rice-elections
 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")
コード例 #3
0
ファイル: intern.py プロジェクト: hwangange/rice-elections
 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")
コード例 #4
0
ファイル: intern.py プロジェクト: gwarr3n/rice-elections
    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()
コード例 #5
0
ファイル: intern.py プロジェクト: pelmers/rice-elections
    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()