mirror of
https://github.com/retspen/webvirtcloud
synced 2026-03-22 10:34:49 +00:00
Added change password permission
Replaces SHOW_PROFILE_EDIT_PASSWORD option Can be set on per user or per group basis
This commit is contained in:
parent
c57ef5ca91
commit
5afa84ee19
4 changed files with 29 additions and 4 deletions
|
|
@ -7,7 +7,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('accounts', '0002_permissionset'),
|
('accounts', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('accounts', '0001_initial'),
|
('accounts', '0002_auto_20200602_1004'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'permissions': (('change_password', 'Can change password'), ),
|
'permissions': (('change_password', 'Can change password'),),
|
||||||
'managed': False,
|
'managed': False,
|
||||||
'default_permissions': (),
|
'default_permissions': (),
|
||||||
},
|
},
|
||||||
25
accounts/migrations/0004_apply_change_password.py
Normal file
25
accounts/migrations/0004_apply_change_password.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def apply_change_password(apps, schema_editor):
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.auth.models import User, Permission
|
||||||
|
|
||||||
|
if hasattr(settings, 'SHOW_PROFILE_EDIT_PASSWORD'):
|
||||||
|
if settings.SHOW_PROFILE_EDIT_PASSWORD:
|
||||||
|
permission = Permission.objects.get(codename='change_password')
|
||||||
|
users = User.objects.all()
|
||||||
|
user: User
|
||||||
|
for user in users:
|
||||||
|
user.user_permissions.add(permission)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('accounts', '0003_permissionset'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(apply_change_password),
|
||||||
|
]
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="offset-2 col-sm-10">
|
||||||
<button type="submit" class="btn btn-primary">{% trans "Change" %}</button>
|
<button type="submit" class="btn btn-primary">{% trans "Change" %}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue