Exemplo n.º 1
0
    def new(self):
        c.signed_in_person = h.signed_in_person()
        c.events = Event.find_all()
        c.schedule = Schedule.find_all()
        c.time_slot = TimeSlot.find_all()
        if not c.signed_in_person.registration:
            return render('/vote/no_rego.mako')
        c.votes = Vote.find_by_rego(c.signed_in_person.registration.id)
        defaults = {'vote.vote_value': 1}
        args = request.GET
        eventid = args.get('eventid', 0)
        revoke = args.get('revoke', 0)
        c.eventid = eventid
        if int(eventid) != 0 and c.votes.count() < 4 and revoke == 0:
            c.vote = Vote()
            c.vote.rego_id = c.signed_in_person.registration.id
            c.vote.vote_value = 1
            c.vote.event_id = eventid
            meta.Session.add(c.vote)
            meta.Session.commit()
        if int(eventid) != 0 and int(revoke) != 0:
            c.vote = Vote.find_by_event_rego(
                eventid, c.signed_in_person.registration.id)
            meta.Session.delete(c.vote)
            meta.Session.commit()
            redirect_to('new')

        form = render('/vote/new.mako')
        return htmlfill.render(form, defaults)
Exemplo n.º 2
0
    def new(self):
        c.signed_in_person = h.signed_in_person()
        c.events = Event.find_all()
        c.schedule = Schedule.find_all()
        c.time_slot = TimeSlot.find_all()
        if not c.signed_in_person.registration:
          return render('/vote/no_rego.mako')
        c.votes = Vote.find_by_rego(c.signed_in_person.registration.id)
        defaults = {
            'vote.vote_value': 1 
        }
        args = request.GET
        eventid = args.get('eventid',0)
        revoke = args.get('revoke',0)
        c.eventid = eventid
        if int(eventid) != 0 and c.votes.count() < 4 and revoke == 0:
            c.vote = Vote()
            c.vote.rego_id = c.signed_in_person.registration.id
            c.vote.vote_value = 1
            c.vote.event_id = eventid
            meta.Session.add(c.vote)
            meta.Session.commit()
        if int(eventid) != 0 and int(revoke) != 0:
            c.vote = Vote.find_by_event_rego(eventid,c.signed_in_person.registration.id)
            meta.Session.delete(c.vote)
            meta.Session.commit()
            redirect_to('new')
  

        form = render('/vote/new.mako')
        return htmlfill.render(form, defaults)
Exemplo n.º 3
0
    def edit(self, id):
        c.vote = Vote.find_by_id(id)

        defaults = h.object_to_defaults(c.vote, 'vote')

        form = render('vote/edit.mako')
        return htmlfill.render(form, defaults)
Exemplo n.º 4
0
    def edit(self, id):
        c.vote = Vote.find_by_id(id)

        defaults = h.object_to_defaults(c.vote, 'vote')

        form = render('vote/edit.mako')
        return htmlfill.render(form, defaults)
Exemplo n.º 5
0
 def _revoke(self):
     args = request.GET
     eventid = int(args.get('eventid',0))
     c.signed_in_person = h.signed_in_person()
     c.vote = Vote.find_by_event_rego(eventid,c.signed_in_person.registration.id)
     meta.Session.delete(c.vote)
     meta.Session.commit()
     redirect_to('new')
Exemplo n.º 6
0
    def _new(self):
        results = self.form_result['vote']

        c.vote = Vote(**results)
        meta.Session.add(c.vote)
        meta.Session.commit()

        h.flash("Vote created")
        redirect_to(action='view', id=c.vote.id)
Exemplo n.º 7
0
    def _edit(self, id):
        vote = Vote.find_by_id(id)

        for key in self.form_result['vote']:
            setattr(vote, key, self.form_result['vote'][key])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("The note has been updated successfully.")
        redirect_to(action='view', id=id)
Exemplo n.º 8
0
    def _edit(self, id):
        vote = Vote.find_by_id(id)

        for key in self.form_result['vote']:
            setattr(vote, key, self.form_result['vote'][key])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("The note has been updated successfully.")
        redirect_to(action='view', id=id)
Exemplo n.º 9
0
    def revoke(self):
        """Delete the rego note

        GET will return a form asking for approval.

        POST requests will delete the item.
        """
        args = request.GET
        eventid = int(args.get('eventid',0))
        c.signed_in_person = h.signed_in_person()
        c.vote = Vote.find_by_event_rego(eventid,c.signed_in_person.registration.id)
        meta.Session.delete(c.vote)
        meta.Session.commit()
        form = render('/vote/delete.mako')
        return htmlfill.render(form, defaults)
        redirect_to('new')
Exemplo n.º 10
0
 def index(self):
     c.vote_collection = Vote.find_all()
     # return render('vote/list.mako')
     redirect_to(action='new')
Exemplo n.º 11
0
 def index(self):
     c.vote_collection = Vote.find_all()
     # return render('vote/list.mako')
     redirect_to(action='new')