예제 #1
0
파일: sites.py 프로젝트: frankk00/openblock
 def login(self, request):
     """
     Displays the login form
     """
     from ebpub.accounts.views import login
     request.session['next_url'] = request.get_full_path()
     return login(request)
예제 #2
0
 def login(self, request):
     """
     Displays the login form
     """
     from ebpub.accounts.views import login
     request.session['next_url'] = request.get_full_path()
     return login(request)
예제 #3
0
def finish_signup(request, place, data):
    # This is called from signup(), after `data` (the alert options) is
    # validated/cleaned. This is a separate function so signup() doesn't get
    # too unwieldy.

    # First, delete displayed_schemas and selected_schemas, because neither is
    # used in serialization. Also, convert `schemas` to be a string list of IDs
    # instead of the model objects, because that's what we end up storing in
    # the database.
    del data['displayed_schemas']
    del data['selected_schemas']
    data['schemas'] = ','.join([str(s.id) for s in data['schemas']])
    if isinstance(place, Block):
        data['block_center'] = place.geom.centroid.wkt
        data['location_id'] = None
    else:
        data['block_center'] = None
        data['location_id'] = place.id
        data['radius'] = None

    if not request.user.is_anonymous():
        email = request.user.email
    else:
        email = data['email']

    if request.user.is_authenticated():
        message = callbacks.create_alert(request.user, data)
        request.session['login_message'] = message
        return http.HttpResponseRedirect(reverse('accounts-dashboard'))

    try:
        User.objects.get(email=email)
    except User.DoesNotExist:
        # We haven't seen this e-mail address yet, so send out a confirmation
        # e-mail to create the account. But first, save the user's alert
        # information so we can create the alert once the user confirms the
        # e-mail address. (We don't want to send the alert options in that
        # confirmation e-mail, because that's too much data to pass in a URL.)
        PendingUserAction.objects.create(
            email=email,
            callback='createalert',
            data=callbacks.serialize(data),
            action_date=datetime.datetime.now(),
        )
        return send_confirmation_and_redirect(request, email, CREATE_TASK)
    else:
        # This e-mail address already has an account, so show a password
        # confirmation screen.
        msg = "You already have an account with this e-mail address. " \
              "Please enter your password to confirm this alert subscription."
        request.session['pending_login'] = ('createalert', data)
        return login(request,
                     custom_message=msg,
                     force_form=True,
                     initial_email=email)
예제 #4
0
파일: views.py 프로젝트: frankk00/openblock
def finish_signup(request, place, data):
    # This is called from signup(), after `data` (the alert options) is
    # validated/cleaned. This is a separate function so signup() doesn't get
    # too unwieldy.

    # First, delete displayed_schemas and selected_schemas, because neither is
    # used in serialization. Also, convert `schemas` to be a string list of IDs
    # instead of the model objects, because that's what we end up storing in
    # the database.
    del data['displayed_schemas']
    del data['selected_schemas']
    data['schemas'] = ','.join([str(s.id) for s in data['schemas']])
    if isinstance(place, Block):
        data['block_id'] = place.id
        data['location_id'] = None
    else:
        data['block_id'] = None
        data['location_id'] = place.id
        data['radius'] = None

    if not request.user.is_anonymous():
        email = request.user.email
    else:
        email = data['email']

    if request.user:
        message = callbacks.create_alert(request.user, data)
        request.session['login_message'] = message
        return http.HttpResponseRedirect('/accounts/dashboard/')

    try:
        user = User.objects.get(email=email)
    except User.DoesNotExist:
        # We haven't seen this e-mail address yet, so send out a confirmation
        # e-mail to create the account. But first, save the user's alert
        # information so we can create the alert once the user confirms the
        # e-mail address. (We don't want to send the alert options in that
        # confirmation e-mail, because that's too much data to pass in a URL.)
        PendingUserAction.objects.create(
            email=email,
            callback='createalert',
            data=callbacks.serialize(data),
            action_date=datetime.datetime.now(),
        )
        return send_confirmation_and_redirect(request, email, CREATE_TASK)
    else:
        # This e-mail address already has an account, so show a password
        # confirmation screen.
        msg = "You already have an account with this e-mail address. " \
              "Please enter your password to confirm this alert subscription."
        request.session['pending_login'] = ('createalert', data)
        return login(request, custom_message=msg, force_form=True, initial_email=email)