Exemple #1
0
def create_board(request):

    if request.POST:
        form = BoardForm(request.user, request.POST)

        if form.is_valid():

            new_board = Board()
            new_board.save()

            if request.user.is_authenticated():
                new_board.owner = request.user
                profile = request.user.get_profile()
                if profile.is_premium:
                    profile.boardinos.add(new_board)
                    profile.save()
                    new_board.is_private = True

            new_board.save()

            welcomePostit = PostIt(text=_("Welcome! Move me! Edit me! Delete me!"),x=120,y=50, board=new_board, width=100,
                                   height=100)
            sharePostit = PostIt(text=_("Share this board and work together in realtime!")+ "\n\nhttp://www.boardino.com/"+new_board.hash,
                            x=200,
                            y=300,
                            board=new_board,
                            width=220,
                            height=100,
                            back_color='#FF69B4')
            comeBackPostit = PostIt(text=_("Come back to check new features!"),x=550,y=50, board=new_board,
                                    width=150,
                                    height=100,
                                    back_color='#ADFF2F')
            welcomePostit.save()
            sharePostit.save()
            comeBackPostit.save()

            return HttpResponseRedirect("/"+new_board.hash)

    return HttpResponseRedirect("/")