forked from modlinltd/django-advanced-filters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test:add test for issue modlinltd#144
- Loading branch information
1 parent
5f56318
commit c36ed33
Showing
5 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 2.2 on 2022-02-23 06:05 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('customers', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Attribute', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name='client', | ||
name='language', | ||
field=models.CharField(choices=[('en', 'English'), ('sp', 'Spanish'), ('it', 'Italian')], default='en', max_length=8), | ||
), | ||
migrations.AddField( | ||
model_name='client', | ||
name='attributes', | ||
field=models.ManyToManyField(blank=True, to='customers.Attribute'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,27 @@ def _prepare(cls, create, **kwargs): | |
return user | ||
|
||
|
||
class AttributeFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = 'customers.Attribute' | ||
|
||
name = factory.Sequence(lambda n: 'attribute%d' % n) | ||
|
||
|
||
class ClientFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = 'customers.Client' | ||
|
||
first_name = factory.faker.Faker('first_name') | ||
email = factory.Sequence(lambda n: 'c%[email protected]' % n) | ||
|
||
@factory.post_generation | ||
def attributes(self, create, extracted, **kwargs): | ||
if not create: | ||
# Simple build, do nothing. | ||
return | ||
|
||
if extracted: | ||
# A list of groups were passed in, use them | ||
for attribute in extracted: | ||
self.attributes.add(attribute) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 2.2 on 2022-02-23 06:05 | ||
|
||
import django.contrib.auth.models | ||
import django.contrib.auth.validators | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('reps', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelManagers( | ||
name='salesrep', | ||
managers=[ | ||
('objects', django.contrib.auth.models.UserManager()), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name='salesrep', | ||
name='last_name', | ||
field=models.CharField(blank=True, max_length=150, verbose_name='last name'), | ||
), | ||
migrations.AlterField( | ||
model_name='salesrep', | ||
name='username', | ||
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username'), | ||
), | ||
] |