Exemplo n.º 1
0
def add_award(request):
    if request.method == 'POST':
        form = AwardForm(request.POST)
        if form.is_valid():
            user = request.user
            title = form.cleaned_data['title']
            date = form.cleaned_data['date']
            description = form.cleaned_data['description']

            award = Award(member=user,
                          title=title,
                          date=date,
                          description=description)
            award.save()

            return redirect('member:profile')
        else:
            return render_to_response('member/add_award.html', {
                'form': form,
            }, RequestContext(request))
    else:
        form = AwardForm()
        return render_to_response('member/add_award.html', {
            'form': form,
        }, RequestContext(request))
Exemplo n.º 2
0
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         badge = Badge(name=post['name'],
                       description=post['description'],
                       category=post['category'],
                       image=post['image'],
                       value=int(post['value']))
         badge.save()
     elif post['kind'] == 'article':
         date = datetime.datetime.strptime(post['date'], '%Y-%m-%d').date()
         article = NewsArticle(title=post['title'],
                               author=post['author'],
                               body=post['body'],
                               date=date)
         article.save()
     elif post['kind'] == 'award':
         badge = Badge.get_by_id(int(post['badge']))
         for member in post.getall('members'):
             member = Member.get_by_id(int(member))
             award = Award(member=member,
                           badge=badge,
                           date=datetime.date.today(),
                           proof=post['proof'])
             award.save()
     elif post['kind'] == 'talk':
         talk = Talk(title=post['title'],
                     date=datetime.datetime.strptime(
                         post['date'], '%Y-%m-%d').date(),
                     description=post['description'],
                     member=Member.get_by_id(int(post['member'])),
                     video=post['video'])
         talk.put()
     self.get()
Exemplo n.º 3
0
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         b = Badge(name=post['name'],
                   description=post['description'],
                   category=post['category'],
                   image=post['image'],
                   value=int(post['value']))
         b.save()
     elif post['kind'] == 'article':
         a = NewsArticle(title=post['title'],
                         author=post['author'],
                         body=post['body'],
                         date=datetime.date.today())
         a.save()
     elif post['kind'] == 'award':
         badge = Badge.gql('WHERE name = :1', post['badge']).get()
         for h in post.getall('hackers'):
             hacker = Hacker.gql('WHERE handle = :1', h).get()
             a = Award(hacker=hacker,
                       badge=badge,
                       date=datetime.date.today(),
                       proof=post['proof'])
             a.save()
             hacker.score_cache = hacker.score + badge.value
             hacker.save()
     self.get()
Exemplo n.º 4
0
    def load_awards(cls, soup, event):
        sections = soup.find_all(
            class_="sites-embed-border-on sites-embed sites-embed-full-width")

        awards = []
        for s in sections:
            title = s.find("h4").text
            if "Award" in title:
                text = cls.AWARD_FILTER.sub("", s.get_text())
                # replacing Place and Winner: with Team compensates for lack of prefixing in some
                # ftcpenn pages
                text = re.sub(r"Place:?", "Team ", text)
                text = re.sub(r"Winner:?", "Team ", text)
                # there's a case in 1415pacmp that fools our award detector.
                # oops!
                text = re.sub(r"Teal\s+Team\s+6", "", text)
                title = re.sub(r"Award.*$", "Award", title)

                winners = cls.TEAM_AWARD.findall(text)
                award_type = AwardType.get_type(title)
                for i, t in enumerate(winners, 1):
                    a = Award(name=title,
                              award_type=award_type,
                              event_key=event.key,
                              team_key='ftc' + t,
                              award_place=i)
                    if i == 1:
                        a.name += " Winner"
                    else:
                        a.name += " Finalist"
                    awards.append(a)
        return awards
Exemplo n.º 5
0
def init_awards():
    db.session.query(Nomination).delete()
    db.session.query(Award).delete()

    award_order = [
        "Best Director",
        "Best Production Manager",
        "Best Stage Manager",
        "Best Technical Director",
        "Best Music Director",
        "Best Choreography",
        "Best Actress in a Lead Role",
        "Best Actor in a Lead Role",
        "Best Supporting Actress",
        "Best Supporting Actor",
        "Best Featured Performer",
        "Best Ensemble",
        "Best Duo",
        "Best Improv Moment",
        "Best Sketch Actor",
        "Best Cover",
        "Worst Cover",
        "Best Set",
        "Best Lighting",
        "Best Sound",
        "Best Costumes",
        "Best Props",
        "Best Publicity",
        "Best Hair & Makeup",
        "Best House",
        "Best Original Work",
        "Best Strike/Load-in Moment",
        "Worst Strike/Load-in Moment",
        "Best Prank",
        "Most Likely to Injure Oneself",
        "Kevin Perry Technical Insanity Award",
        "Donkeypunch Award",
        "Coolest Rookie",
        "Coolest Veteran",
        "Party Animal",
        "Darren M. Canady Sassypants Award",
        "Cutest Couple",
        "Cutest Potential Couple",
        "Most Successful Flirt",
        "Least Successful Flirt",
        "Most Corrupted",
        "Shannon Deep S'n'S Mom Award",
        'The "It Sounded Like A Good Idea at the Time" Award',
        "King and Queen of the Black Chairs Award",
        "Best Late Show Moment",
        "Nathaniel Biggs Coolest Uncle Award",
        "Nathan Blinn Best Black Chairs Argument",
        "New Kudos Category",
        "Retire a Kudos Category",
    ]

    for i in range(len(award_order)):
        db.session.add(Award(name=award_order[i], order=(i + 1) * 10))

    db.session.commit()
Exemplo n.º 6
0
    async def generate_winners_finalists(cls, event, fail_silent=False):
        finals = (await MatchHelper.get_match_data(
            where="m.comp_level='f' AND m.event_key=$1",
            addn_sql="ORDER BY m.match_number",
            params=(event.key, )))
        #print(finals)
        if len(finals) == 0:
            if event.event_type == EventType.MEET:
                return
            logging.warning(
                f"[award_helper.py]: {event.key} doesn't have finals matches wtf"
            )
            if not fail_silent:
                raise Exception(f"query failed on {event.key} oops")
            return
        last_finals = finals[-1]
        if last_finals['m'].winner == 'red':
            winning_alliance = last_finals['red'].teams
            finalist_alliance = last_finals['blue'].teams
        else:
            winning_alliance = last_finals['blue'].teams
            finalist_alliance = last_finals['red'].teams
        awards = []
        for idx, team in enumerate(winning_alliance, 1):
            a = Award(name=event.award_prefix + "Winner",
                      award_type=AwardType.WINNING_ALLIANCE,
                      award_place=idx,
                      event_key=event.key,
                      team_key=team)
            awards.append(a)

        for idx, team in enumerate(finalist_alliance, 1):
            a = Award(name=event.award_prefix + "Finalist",
                      award_type=AwardType.FINALIST_ALLIANCE,
                      award_place=idx,
                      event_key=event.key,
                      team_key=team)
            awards.append(a)
        async with orm.pool.acquire() as conn:
            for a in awards:
                await a.upsert(conn=conn)
Exemplo n.º 7
0
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         badge = Badge(name=post['name'],
                       description=post['description'],
                       category=post['category'],
                       image=post['image'],
                       value=int(post['value']))
         badge.save()
     elif post['kind'] == 'award':
         badge = Badge.get_by_id(int(post['badge']))
         for member in post.getall('members'):
             member = Member.get_by_id(int(member))
             award = Award(member=member,
                           badge=badge,
                           date=datetime.date.today(),
                           proof=post['proof'])
             award.save()
             member.score += badge.value
             member.save()
     elif post['kind'] == 'talk':
         talk = Talk(title=post['title'],
                     date=utils.parse_date(post['date']),
                     description=post['description'],
                     member=Member.get_by_id(int(post['member'])),
                     video=post['video'])
         talk.put()
     elif post['kind'] == 'taglineform':
         properties = GeneralSiteProperties.all().get()
         if properties == None:
             properties = GeneralSiteProperties(tag_line=post['tagline'])
             properties.put()
         else:
             properties.tag_line = post['tagline']
             properties.put()
     self.get()