Exemplo n.º 1
0
def mybots(request):
    user_prof = UserProfile.objects.get(user=request.user)
    if request.method == 'POST':
        form = BotBufferForm(request.POST)
        if not form.is_valid():
            print "ERROR in form!"
            return
        new_code = form.cleaned_data['code']
        user_prof.code = new_code

        if 'publish_buffer' in request.POST:
            bot = Bot()
            bot.owner = user_prof
            bot.code = new_code
            bot.save()
            validate_bot.delay(bot.id, new_code)
            user_prof.current_bot = bot

        user_prof.save()
        return redirect('/mybots')
    else:
        form = BotBufferForm(instance=user_prof)

    return render(request, "my_bots.html", {
        'form': form,
        'user_prof': user_prof,
        'tab': 'mybots',
        'my_bots': reversed(Bot.objects.filter(owner=user_prof))
    })
Exemplo n.º 2
0
 def validate_bot(self, request, queryset):
     for bot in queryset:
         validate_bot.delay(bot.id, bot.code)