From 633660c602e53466e8a341d565814a8335a2843e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 10 Dec 2018 11:15:53 +0100 Subject: [PATCH] =?UTF-8?q?core:=20make=20FieldMatcherRule=E2=80=99s=20use?= =?UTF-8?q?r=5Ffield=20into=20dropdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- passbook/core/forms/rules.py | 1 - .../core/migrations/0002_auto_20181210_1011.py | 18 ++++++++++++++++++ passbook/core/models.py | 12 +++++++++++- passbook/core/templates/overview/base.html | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 passbook/core/migrations/0002_auto_20181210_1011.py diff --git a/passbook/core/forms/rules.py b/passbook/core/forms/rules.py index 9b179acac..a6ae9310b 100644 --- a/passbook/core/forms/rules.py +++ b/passbook/core/forms/rules.py @@ -15,7 +15,6 @@ class FieldMatcherRuleForm(forms.ModelForm): fields = GENERAL_FIELDS + ['user_field', 'match_action', 'value', ] widgets = { 'name': forms.TextInput(), - 'user_field': forms.TextInput(), 'value': forms.TextInput(), } diff --git a/passbook/core/migrations/0002_auto_20181210_1011.py b/passbook/core/migrations/0002_auto_20181210_1011.py new file mode 100644 index 000000000..176a4590b --- /dev/null +++ b/passbook/core/migrations/0002_auto_20181210_1011.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.4 on 2018-12-10 10:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('passbook_core', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='fieldmatcherrule', + name='user_field', + field=models.TextField(choices=[('username', 'username'), ('first_name', 'first_name'), ('last_name', 'last_name'), ('email', 'email'), ('is_staff', 'is_staff'), ('is_active', 'is_active'), ('data_joined', 'data_joined')]), + ), + ] diff --git a/passbook/core/models.py b/passbook/core/models.py index 4e77c807f..d86992226 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -141,7 +141,17 @@ class FieldMatcherRule(Rule): (MATCH_EXACT, _('Exact')), ) - user_field = models.TextField() + USER_FIELDS = ( + ('username', 'username',), + ('first_name', 'first_name',), + ('last_name', 'last_name',), + ('email', 'email',), + ('is_staff', 'is_staff',), + ('is_active', 'is_active',), + ('data_joined', 'data_joined',), + ) + + user_field = models.TextField(choices=USER_FIELDS) match_action = models.CharField(max_length=50, choices=MATCHES) value = models.TextField() diff --git a/passbook/core/templates/overview/base.html b/passbook/core/templates/overview/base.html index 2cc450125..39345f100 100644 --- a/passbook/core/templates/overview/base.html +++ b/passbook/core/templates/overview/base.html @@ -83,4 +83,4 @@ $().setupVerticalNavigation(true); }); -{% endblock %} \ No newline at end of file +{% endblock %}