kpsul/gestioncof/migrations/0015_unique_login_clipper.py

39 lines
1.1 KiB
Python
Raw Permalink Normal View History

core -- Install django-allauth-ens Refer to allauth doc for an accurate features list: http://django-allauth.readthedocs.io/en/latest/ Users can now change their password, ask for a password reset, or set one if they don't have one. In particular, it allows users whose account has been created via a clipper authentication to configure a password before losing their clipper. Even if they have already lost it, they are able to get one using the "Reset password" functionality. Allauth multiple emails management is deactivated. Requests to the related url redirect to the home page. All the login and logout views are replaced by the allauth' ones. It also concerns the Django and Wagtail admin sites. Note that users are no longer logged out of the clipper CAS server when they authenticated via this server. Instead a message suggests the user to disconnect. Clipper connections and `login_clipper` --------------------------------------- - Non-empty `login_clipper` are now unique among `CofProfile` instances. - They are created once for users with a non-empty 'login_clipper' (with the data migration 0014_create_clipper_connections). - The `login_clipper` of CofProfile instances are sync with their clipper connections: * `CofProfile.sync_clipper_connections` method updates the connections based on `login_clipper`. * Signals receivers `sync_clipper…` update `login_clipper` based on connections creations/updates/deletions. Misc ---- - Add NullCharField (model field) which allows to use `unique=True` on CharField (even with empty strings). - Parts of kfet mixins for TestCase are now in shared.tests.testcase, as they are used elsewhere than in the kfet app.
2017-10-19 01:12:52 +02:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import utils.models
def convert_empty_clipper(apps, schema_editor):
CofProfile = apps.get_model("gestioncof", "CofProfile")
CofProfile.objects.filter(login_clipper="").update(login_clipper=None)
class Migration(migrations.Migration):
dependencies = [("gestioncof", "0014_cofprofile_mailing_unernestaparis")]
operations = [
migrations.AlterField(
model_name="cofprofile",
name="login_clipper",
field=models.CharField(
verbose_name="Login clipper",
max_length=32,
null=True,
blank=True,
default="",
),
),
migrations.RunPython(convert_empty_clipper),
migrations.AlterField(
model_name="cofprofile",
name="login_clipper",
field=utils.models.NullCharField(
verbose_name="Login clipper", max_length=32, default="", unique=True
),
),
]