def emaillogin(request, template_name='registration/login.html', auth_form=EmailAuthenticationForm, redirect_field_name=REDIRECT_FIELD_NAME): "Displays the login form and handles the login action. Altered to use the EmailAuthenticationForm" redirect_to = request.REQUEST.get(redirect_field_name, '') # Avoid redirecting to logout if the user clicked on login after logout if redirect_to == urlresolvers.reverse('auth_logout'): redirect_to = None success, todo = _login(request, redirect_to) if success: # return the response redirect return todo else: # continue with the login form form = todo request.session.set_test_cookie() if Site._meta.installed: current_site = Site.objects.get_current() else: current_site = RequestSite(request) return render_to_response(template_name, { 'form': form, redirect_field_name: redirect_to, 'site_name': current_site.name, "page_info": _get_page_parameters(), }, context_instance=RequestContext(request))
def activate(request, activation_key, template='registration/activate.html'): """ Activates a user's account, if their key is valid and hasn't expired. """ activation_key = activation_key.lower() account = AdminRegistrationProfile.objects.activate_user(activation_key) if account: # ** hack for logging in the user ** # when the login form is posted, user = authenticate(username=data['username'], password=data['password']) # ...but we cannot authenticate without password... so we work-around authentication account.backend = settings.AUTHENTICATION_BACKENDS[0] contact = Contact.objects.get(user=account) #send_welcome_email(contact.email, contact.first_name, contact.last_name) # Send an email to the user if an Administrator has activated his/her account if config_value('SHOP', 'ACCOUNT_VERIFICATION') == "ADMINISTRATOR": site = Site.objects.get_current() profile = AdminRegistrationProfile.objects.get(user=account) profile.send_welcome_email(site) template = 'registration/administrator_activate.html' else: # Otherwise login the user as he/she is the one activating his/her account _login(request, account) request.session[CUSTOMER_ID] = contact.id signals.satchmo_registration_verified.send(contact, contact=contact) context = RequestContext( request, { 'account': account, 'expiration_days': config_value('SHOP', 'ACCOUNT_ACTIVATION_DAYS'), "page_info": _get_page_parameters(), }) return render_to_response(template, context_instance=context)
def activate(request, activation_key, template = 'registration/activate.html'): """ Activates a user's account, if their key is valid and hasn't expired. """ activation_key = activation_key.lower() account = AdminRegistrationProfile.objects.activate_user(activation_key) if account: # ** hack for logging in the user ** # when the login form is posted, user = authenticate(username=data['username'], password=data['password']) # ...but we cannot authenticate without password... so we work-around authentication account.backend = settings.AUTHENTICATION_BACKENDS[0] contact = Contact.objects.get(user=account) #send_welcome_email(contact.email, contact.first_name, contact.last_name) # Send an email to the user if an Administrator has activated his/her account if config_value('SHOP', 'ACCOUNT_VERIFICATION') == "ADMINISTRATOR": site = Site.objects.get_current() profile = AdminRegistrationProfile.objects.get(user=account) profile.send_welcome_email(site) template = 'registration/administrator_activate.html' else: # Otherwise login the user as he/she is the one activating his/her account _login(request, account) request.session[CUSTOMER_ID] = contact.id signals.satchmo_registration_verified.send(contact, contact=contact) context = RequestContext(request, { 'account': account, 'expiration_days': config_value('SHOP', 'ACCOUNT_ACTIVATION_DAYS'), "page_info": _get_page_parameters(), }) return render_to_response(template, context_instance=context)
def complete(request): context = { 'verification': config_value('SHOP', 'ACCOUNT_VERIFICATION') ,"page_info": _get_page_parameters() } return render_to_response('registration/registration_complete.html', context, context_instance=RequestContext(request))
def complete(request): context = { 'verification': config_value('SHOP', 'ACCOUNT_VERIFICATION'), "page_info": _get_page_parameters() } return render_to_response('registration/registration_complete.html', context, context_instance=RequestContext(request))
def register(request, redirect=None, template='registration/registration_form.html'): """ Allows a new user to register an account. """ #print("Request post : %s" % request.POST) ret = register_handle_form(request, redirect) success = ret[0] todo = ret[1] if len(ret) > 2: extra_context = ret[2] else: extra_context = {} if success: return todo else: if config_get_group('NEWSLETTER'): show_newsletter = True else: show_newsletter = False context = {'form': todo, 'show_newsletter': show_newsletter} if extra_context: context.update(extra_context) context.update({"page_info": _get_page_parameters()}) # register to update if request.method == "POST": form_object = UpdatesRegistrationForm(request.POST) form_updates_registration = UpdatesRegistrationFormManager( form_object, request) form_success = form_updates_registration.validate() if form_success: return form_updates_registration.notify_and_redirect() else: form_object = UpdatesRegistrationForm() form_updates_registration = UpdatesRegistrationFormManager( form_object, request) context.update({ "form_updates_registration": form_updates_registration.render_html() }) return render_to_response(template, context, context_instance=RequestContext(request))
def register(request, redirect=None, template='registration/registration_form.html'): """ Allows a new user to register an account. """ #print("Request post : %s" % request.POST) ret = register_handle_form(request, redirect) success = ret[0] todo = ret[1] if len(ret) > 2: extra_context = ret[2] else: extra_context = {} if success: return todo else: if config_get_group('NEWSLETTER'): show_newsletter = True else: show_newsletter = False context = { 'form': todo, 'show_newsletter' : show_newsletter } if extra_context: context.update(extra_context) context.update({"page_info": _get_page_parameters()}) # register to update if request.method == "POST": form_object = UpdatesRegistrationForm(request.POST) form_updates_registration = UpdatesRegistrationFormManager(form_object, request) form_success = form_updates_registration.validate() if form_success: return form_updates_registration.notify_and_redirect() else: form_object = UpdatesRegistrationForm() form_updates_registration = UpdatesRegistrationFormManager(form_object, request) context.update({"form_updates_registration": form_updates_registration.render_html()}) return render_to_response(template, context, context_instance=RequestContext(request))
def gallery(request, page=None, current_page=None, category=None, page_number=1, reverse_url="vcms.image_gallery.views.gallery"): reverse_kwargs={} try: page = request.current_page['current_page'] except: raise Http404 if len(request.cms_menu_extrapath) == 2: category = request.cms_menu_extrapath[0] page_number = request.cms_menu_extrapath[1] if len(request.cms_menu_extrapath): if request.cms_menu_extrapath[0].isdigit(): page_number = request.cms_menu_extrapath[0] else: category = request.cms_menu_extrapath[0] page_info = _get_page_parameters(page) reverse_kwargs['page'] = page.slug if category: images_category = ImageCategory.objects.get_image_category_from_slug(category) reverse_kwargs['category'] = category images = page.get_all_images_for_category(images_category) else: images = page.get_all_images() thumbnail_size = str(page.thumbnail_width) + 'x' + str(page.thumbnail_height) paginator = Paginator(images, page.thumbnail_per_page) if int(page_number) > int(paginator.num_pages): page_number = paginator.num_pages paginator_html = pgenerator.get_page_navigation(paginator, page_number, reverse_url, reverse_kwargs=reverse_kwargs) paginator_page = paginator.page(page_number) start_index = paginator_page.start_index()-1 end_index = paginator_page.end_index() return render_to_response('gallery_content.html' ,{ 'gallery_categories': page.get_image_categories() ,'gallery_images': images[start_index:end_index] ,'gallery_page': page ,'page_category': category ,'thumbnail_size': thumbnail_size ,'paginator_html': paginator_html ,'page_info': page_info } ,context_instance=RequestContext(request))