core: make FieldMatcherRule’s user_field into dropdown

This commit is contained in:
Jens Langhammer 2018-12-10 11:15:53 +01:00
parent 19a8ecb55a
commit 633660c602
4 changed files with 30 additions and 3 deletions

View file

@ -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(),
}

View file

@ -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')]),
),
]

View file

@ -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()

View file

@ -83,4 +83,4 @@
$().setupVerticalNavigation(true);
});
</script>
{% endblock %}
{% endblock %}