Exemplo n.º 1
0
def add_page(request, url, html):
    if not url.startswith('http://') and not url.startswith('https://'):
        return helpers.redirect(url, 'This type of page cannot be added to a flowgram.')

    user = request.user
    title = helpers.get_title(request)

    (flowgram, page) = pages.add_page(user, url, html, title)

    log.action('add_page created page with ID %s for Flowgram with ID %s by user %s' % \
                   (page.id, flowgram.id, user.username))
    return helpers.redirect(url, 'Page added to your Flowgram "%s"' % flowgram.title)
Exemplo n.º 2
0
def login(request, enc):
    next = request.GET.get('next', '/')

    if request.user.is_authenticated():
        return helpers.redirect(next)
    
    next_greeting = ''
    if next.find('create') >= 0:
        next_greeting = "Please login or register to get started making Flowgrams. It's quick and easy!"
    elif next.find('subscribe') >= 0:
        next_greeting = "Please login or register to subscribe to a user. It's quick and easy!"
    
    if request.method == 'POST':
        succeeded = False
        form = forms.LoginForm(request.POST)

        if form.is_valid():
            user = auth.authenticate(username=form.cleaned_data['username'],
                                     password=form.cleaned_data['password'])
            assert(user)
            auth.login(request, user)
            request.session[settings.PERSISTENT_SESSION_KEY] = form.cleaned_data['remember_user']
            succeeded = True

        if not succeeded:
            request.session['processed_login_form'] = form.as_p()
            controller.record_stat(request, 'view_login_website', '0', 'unsuccessful')
            return HttpResponseRedirect('/login')

        next = request.POST.get('next', '')
        if next:
            controller.record_stat(request,
                                   'view_login_website',
                                   '0',
                                   'successful, next url = %s' % next)
            return helpers.redirect(next)

        controller.record_stat(request, 'view_login_website', '0', 'successful, next url = /')
        return HttpResponseRedirect('/')
    else:
        form = forms.LoginForm()
        reg_form = forms.RegistrationFormStep1()
        return helpers.req_render_to_response(request,
                                              'login/login.html',
                                              {'next': next,
                                               'next_greeting': next_greeting,
                                               'reg_form': reg_form,
                                               'which_form_reg': 'register_step_1'})
Exemplo n.º 3
0
def create_easy(request, enc):
    (flowgram, new) = controller.get_working_flowgram(request.user)

    hash_parts = ["%s-%s" % (key, request.GET[key]) for key in sorted(request.GET.keys())]

    controller.record_stat(request, "view_create_website", "0", "")

    return helpers.redirect("/r/%s/%s" % (flowgram.id, "__".join(hash_parts)))