Exemplo n.º 1
0
    def save(self, request):
        data = self.cleaned_data
        topic = Topic(
            user=request.user,
            subject=data['subject'],
            subject_english=data['subject_english'],
            content=data['content'],
            content_english=data['content_english'],
            deadline=data['deadline'],
            event_close_date=data['event_close_date'],
            end_weight=data['end_weight'],
        )
        topic.save()
        pay_topic_post(topic)

        for tag in data['tags']:
            topic.tags.add(tag)

        if data.get('yesno') is not None and data.get('score'):
            bet = Bet(
                user=request.user,
                topic=topic,
                score=data['score'],
                weight=get_current_weight(topic),
                yesno=data['yesno'],
            )
            bet.save()
            pay_bet(bet)

        return topic
Exemplo n.º 2
0
 def save(self, request, topic):
     data = self.cleaned_data
     bet = Bet(
         user=request.user,
         topic=topic,
         score=data['score'],
         weight=get_current_weight(topic),
         yesno=data['yesno'],
     )
     bet.save()
     pay_bet(bet)