예제 #1
0
파일: log.py 프로젝트: BlowBlood/blowblood
 def wrapper(self, *args, **kwargs):
     counter = Counter.all().get()
     if counter is None:
         counter = Counter()
         counter.put()
     if not users.is_current_user_admin():
         counter.count += 1
         counter.put()
     return handler_method(self, *args, **kwargs)
예제 #2
0
def votes_constructor():
    votes = Votes(president=Counter(),
                  gobernor=Counter(),
                  diputado=Counter(),
                  senador=Counter(),
                  intendente=Counter(),
                  general=Counter())
    votes.save()
    return votes
예제 #3
0
def load_votes_matrix(box):
    parties = []
    parties_matrix = zip(PARTIES, VOTES_MATRIX)
    for party, flags in dict(parties_matrix).items():
        kwargs = {}
        for i, flag in enumerate(flags):
            counter = Counter(enabled=bool(flag))
            kwargs[CANDIDATES[i]] = counter
        _votes = Votes(**kwargs)
        _votes.save()
        _party = Party(name=party, votes=_votes)
        _party.save()
        parties.append(_party)
    box.parties = parties
    box.save()
    other_votes = OtherVotes(blank=votes_constructor(),
                             nulled=votes_constructor(),
                             recurrent=votes_constructor(),
                             refuted=votes_constructor()).save()
    box.other_votes = other_votes
    box.save()
예제 #4
0
from flask import Flask
from model import Counter
# Init a flask app
app = Flask()
count = Counter()