Example #1
0
class RegistrationAdmin(admin.ModelAdmin):
    actions = ['activate_users', 'resend_activation_email']
    list_display = ('user', 'activation_key_expired')
    raw_id_fields = ['user']
    search_fields = ('user__{0}'.format(UsernameField()), 'user__first_name', 'user__last_name')

    def activate_users(self, request, queryset):
        """
        Activates the selected users, if they are not already
        activated.

        """
        for profile in queryset:
            RegistrationProfile.objects.activate_user(profile.activation_key)
    activate_users.short_description = _("Activate users")

    def resend_activation_email(self, request, queryset):
        """
        Re-sends activation emails for the selected users.

        Note that this will *only* send activation emails for users
        who are eligible to activate; emails will not be sent to users
        whose activation keys have expired or who have already
        activated.

        """
        if Site._meta.installed:
            site = Site.objects.get_current()
        else:
            site = RequestSite(request)

        for profile in queryset:
            if not profile.activation_key_expired():
                profile.send_activation_email(site)
    resend_activation_email.short_description = _("Re-send activation emails")
Example #2
0
    def test_registration_form_adds_custom_user_name_field(self):
        """
        Test that ``RegistrationForm`` adds custom username
        field and does not raise errors

        """

        form = forms.RegistrationForm()

        self.assertTrue(UsernameField() in form.fields)
Example #3
0
class RegistrationAdmin(admin.ModelAdmin):
    actions = ['activate_users', 'resend_activation_email']
    list_display = ('user', 'activation_key_expired')
    raw_id_fields = ['user']
    search_fields = ('user__{0}'.format(UsernameField()), 'user__first_name',
                     'user__last_name')

    def activate_users(self, request, queryset):
        """
        Activates the selected users, if they are not already
        activated.

        """
        for profile in queryset:
            RegistrationProfile.objects.activate_user(profile.activation_key)

    activate_users.short_description = _("Activate users")
Example #4
0
class MyRegistrationAdmin(admin.ModelAdmin):
    actions = ['activate_users', 'resend_activation_email']
    list_display = ('user', 'activation_key_expired')
    search_fields = ('user__{0}'.format(UsernameField()), 'user__first_name',
                     'user__last_name')

    def activate_users(self, request, queryset):
        """
		Activates the selected users, if they are not already
		activated.
		"""

        site = get_current_site(request)
        for profile in queryset:
            RegistrationProfile.objects.activate_user(profile.activation_key,
                                                      site)

    activate_users.short_description = ugettext_lazy("Activate users")

    def resend_activation_email(self, request, queryset):
        """
		Re-sends activation emails for the selected users.
		Note that this will *only* send activation emails for users
		who are eligible to activate; emails will not be sent to users
		whose activation keys have expired or who have already
		activated.
		"""

        site = get_current_site(request)
        for profile in queryset:
            user = profile.user
            RegistrationProfile.objects.resend_activation_mail(
                user.email, site, request)

    resend_activation_email.short_description = ugettext_lazy(
        "Re-send activation emails")
Example #5
0
 class Meta:
     model = User
     fields = ('email', 'first_name', 'last_name', UsernameField())
Example #6
0
 class Meta:
     model = User
     fields = (UsernameField(), 'first_name', 'last_name', "email")
Example #7
0
 class Meta:
     model = UserModel()
     fields = ('first_name', 'last_name', UsernameField(), "email")
Example #8
0
 class Meta:
     model = User
     fields = (UsernameField(), "email", "sponsor_name")
Example #9
0
 class Meta:
     model = User
     fields = (UsernameField(), "email")
Example #10
0
 class Meta:
     model = CustomUser
     fields = (UsernameField(), 'email')
Example #11
0
 class Meta:
     model = User
     fields = (UsernameField(), "email", "first_name")