0001-manager-show-user-deletion-status-36788.patch
src/authentic2/manager/templates/authentic2/manager/user_detail.html | ||
---|---|---|
42 | 42 | |
43 | 43 |
{% block other_actions %} |
44 | 44 | |
45 |
{% if object.deletion %} |
|
46 |
<p class="a2-manager-user-deletion"> |
|
47 |
{% blocktrans with date=object.deletion.creation %}Prepared for deletion since {{ date }}{% endblocktrans %} |
|
48 |
</p> |
|
49 |
{% endif %} |
|
50 | ||
45 | 51 |
<p class="a2-manager-user-last-login"> |
46 | 52 |
{% if object.last_login %} |
47 | 53 |
{% blocktrans with date=object.last_login %}Last login on {{ date }}.{% endblocktrans %} |
src/authentic2/migrations/0025_auto_20191009_1047.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# Generated by Django 1.11.20 on 2019-10-09 08:47 |
|
3 |
from __future__ import unicode_literals |
|
4 | ||
5 |
from django.conf import settings |
|
6 |
from django.db import migrations, models |
|
7 |
import django.db.models.deletion |
|
8 | ||
9 | ||
10 |
class Migration(migrations.Migration): |
|
11 | ||
12 |
dependencies = [ |
|
13 |
('authentic2', '0024_auto_20190617_1113'), |
|
14 |
] |
|
15 | ||
16 |
operations = [ |
|
17 |
migrations.AlterField( |
|
18 |
model_name='deleteduser', |
|
19 |
name='user', |
|
20 |
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='deletion', to=settings.AUTH_USER_MODEL, verbose_name='user'), |
|
21 |
), |
|
22 |
] |
src/authentic2/models.py | ||
---|---|---|
47 | 47 | |
48 | 48 |
objects = managers.DeletedUserManager() |
49 | 49 | |
50 |
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('user')) |
|
50 |
user = models.OneToOneField( |
|
51 |
to=settings.AUTH_USER_MODEL, |
|
52 |
related_name='deletion', |
|
53 |
verbose_name=_('user')) |
|
51 | 54 |
creation = models.DateTimeField(auto_now_add=True, verbose_name=_('creation date')) |
52 | 55 | |
53 | 56 |
class Meta: |
tests/test_user_manager.py | ||
---|---|---|
29 | 29 |
from django_rbac.utils import get_ou_model |
30 | 30 | |
31 | 31 |
from authentic2.custom_user.models import User |
32 |
from authentic2.models import Attribute, AttributeValue |
|
32 |
from authentic2.models import Attribute, AttributeValue, DeletedUser
|
|
33 | 33 |
from authentic2.a2_rbac.utils import get_default_ou |
34 | 34 |
from authentic2.manager import user_import |
35 | 35 | |
... | ... | |
426 | 426 |
assert 'birthdate' not in et.attributes.values |
427 | 427 |
assert et.attributes.values['zip'].content == '42000' |
428 | 428 |
assert et.attributes.values['phone'].content == '+8885678' |
429 | ||
430 | ||
431 |
def test_detail_view(app, admin, simple_user): |
|
432 |
url = '/manage/users/{user.id}/'.format(user=simple_user) |
|
433 |
response = login(app, admin, url) |
|
434 |
assert not response.pyquery('.a2-manager-user-deletion') |
|
435 |
DeletedUser.objects.create(user=simple_user) |
|
436 |
response = app.get(url) |
|
437 |
assert response.pyquery('.a2-manager-user-deletion') |
|
429 |
- |