Esempio n. 1
0
def slate(request):
    slateForm = SlateForm(request.POST or None)
    if request.method == 'POST':
        #create slate
        if slateForm.is_valid():

            clean = slateForm.cleaned_data
            if request.user.slate_creator.count() <= 19:
                slate = Slate(
                        name = clean['name'],
                        creator = request.user,
                        description = clean['description']
                        )
                slate.save()
                slate.users.add(request.user)
                return redirect('view-slate', slate_id = slate.id)
            else:
                messages.error(request, 
                        "We're limiting slates to 20 per user for now,"+
                        " we figure that this is more than anyone will really"+
                        " need, but you really want more, contact us at "+
                        "*****@*****.**")

    your_slates = Slate.objects.filter(users=request.user)
    return render_to_response("main/slate.html", locals(),
            context_instance = RequestContext(request))
Esempio n. 2
0
def convert_idea(request, idea_id):
    idea = Idea.objects.get(id = idea_id)

    #check whether the user is the creator of the idea
    if request.user != idea.user:
        return redirect("idea", idea_id)
    #create a slate for the idea
    slate = Slate(
            creator = request.user,
            name = idea.idea,
            description = idea.elaborate
            )
    slate.save()

    #set the idea to private and add it to the slate
    slate.users.add(request.user)
    idea.private = True
    idea.started = True
    idea.save()
    slate.ideas.add(idea)
    slate.save()
    #
    return redirect("view-slate", slate.id)