コード例 #1
0
ファイル: users.py プロジェクト: profnandaa/kanisa
    def get_redirect_url(self, user_id):
        user = get_object_or_404(get_user_model(), pk=user_id)

        if user.is_active:
            message = ('%s\'s account is already active.'
                       % user.get_familiar_name())
            messages.success(self.request, message)
            return reverse('kanisa_manage_users')

        send_single_mail(user, 'on_account_activation', {})

        send_bulk_mail(users_with_perm('manage_users'),
                       'on_account_activation_staff_notify',
                       {'user': user})

        user.is_active = True
        user.is_spam = False
        user.save()

        message = ('%s\'s account is now activated.'
                   % user.get_familiar_name())
        messages.success(self.request, message)

        cache.delete('kanisa_inactive_users')

        return reverse('kanisa_manage_users')
コード例 #2
0
ファイル: password.py プロジェクト: profnandaa/kanisa
    def send_notification(self):
        context = {
            'site': RequestSite(self.request),
            'token': signing.dumps(self.user.pk, salt=self.salt),
            'secure': self.request.is_secure(),
        }

        send_single_mail(self.user, 'on_forgotten_password', context)
コード例 #3
0
ファイル: password.py プロジェクト: dominicrodger/kanisa
    def send_notification(self):
        context = {
            'site': RequestSite(self.request),
            'token': signing.dumps(self.user.pk, salt=self.salt),
            'secure': self.request.is_secure(),
        }

        send_single_mail(self.user,
                         'on_forgotten_password',
                         context)
コード例 #4
0
ファイル: users.py プロジェクト: profnandaa/kanisa
    def form_valid(self, form):
        username = form.cleaned_data['username']
        first_name = form.cleaned_data['first_name']
        last_name = form.cleaned_data['last_name']
        email = form.cleaned_data['email']

        if not form.cleaned_data['image']:
            # Comes in as False, need to set to None
            image = None
        else:
            image = form.cleaned_data['image']

        if self.request.user.is_superuser:
            is_superuser = form.cleaned_data['administrator']
            is_staff = form.cleaned_data['administrator']
        else:
            is_superuser = False
            is_staff = False

        object = RegisteredUser.objects.create(
            username=username,
            first_name=first_name,
            last_name=last_name,
            email=email,
            image=image,
            is_superuser=is_superuser,
            is_staff=is_staff
        )

        object.set_kanisa_permissions(form.cleaned_data['permissions'])

        password = RegisteredUser.objects.make_random_password()
        object.set_password(password)

        object.save()

        send_single_mail(object,
                         'on_account_creation',
                         {'password': password,
                          'site': RequestSite(self.request), })

        message = ('Registered User "%s" saved.'
                   % object.get_familiar_name())
        messages.success(self.request, message)

        return super(UserCreateView, self).form_valid(form)