Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        super(EmailCodeRegistrationForm, self).__init__(*args, **kwargs)

        # my hack - no need for sign up code if they are in a program
        if get_current_program():
            self.fields['signup_code'] = forms.CharField(max_length=40, required=False, widget=forms.widgets.HiddenInput())
        else:
            self.fields['signup_code'] = forms.CharField(max_length=40, required=False, widget=forms.PasswordInput(),
                                label=_("Signup Code"))
Ejemplo n.º 2
0
    def send_activation_email(self, site):
        """
        Send an activation email to the user associated with this
        ``RegistrationProfile``.
        
        The activation email will make use of two templates:

        ``registration/activation_email_subject.txt``
            This template will be used for the subject line of the
            email. Because it is used as the subject line of an email,
            this template's output **must** be only a single line of
            text; output longer than one line will be forcibly joined
            into only a single line.

        ``registration/activation_email.txt``
            This template will be used for the body of the email.

        These templates will each receive the following context
        variables:

        ``activation_key``
            The activation key for the new account.

        ``expiration_days``
            The number of days remaining during which the account may
            be activated.

        ``site``
            An object representing the site on which the user
            registered; depending on whether ``django.contrib.sites``
            is installed, this may be an instance of either
            ``django.contrib.sites.models.Site`` (if the sites
            application is installed) or
            ``django.contrib.sites.models.RequestSite`` (if
            not). Consult the documentation for the Django sites
            framework for details regarding these objects' interfaces.

        """

        ctx_dict = {'activation_key': self.activation_key,
                    'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
                    'site': site, 
                    # additional for 5000hands
                    'program': tls.get_current_program(),
                    'program_domain': tls.get_current_domain(),
                    }
        subject = render_to_string('registration/activation_email_subject.txt',
                                   ctx_dict)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())
        
        message = render_to_string('registration/activation_email.txt',
                                   ctx_dict)
        
        self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
Ejemplo n.º 3
0
    def __init__(self, user, profile, *args, **kwargs):
        super(FacebookUserForm, self).__init__(*args, **kwargs)
        self.user = user
        self.profile = profile

        if settings.REGISTRATION_REQUIRE_SIGNUP_CODE:
            # my hack - no need for sign up code if they are in a program
            if get_current_program():
                self.fields['signup_code'] = forms.CharField(max_length=40, required=False, widget=forms.widgets.HiddenInput())
            else:
                self.fields['signup_code'] = forms.CharField(max_length=40, required=False, widget=forms.PasswordInput(),
                                    label=_("Signup Code"))
Ejemplo n.º 4
0
    def clean_signup_code(self):
        code = self.cleaned_data.get("signup_code")

        # my hack - no need to use signup if they are in a program
        if get_current_program():
            signup_code = True
        else:
            signup_code = check_signup_code(code)

        if signup_code:
            return signup_code
        else:
            raise forms.ValidationError("Signup code was not valid.")