本文整理汇总了Python中core.models.Person.get_or_create_dummy方法的典型用法代码示例。如果您正苦于以下问题:Python Person.get_or_create_dummy方法的具体用法?Python Person.get_or_create_dummy怎么用?Python Person.get_or_create_dummy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.Person
的用法示例。
在下文中一共展示了Person.get_or_create_dummy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def setUp(self):
self.meta, unused = BadgesEventMeta.get_or_create_dummy()
LabourEventMeta.get_or_create_dummy()
ProgrammeEventMeta.get_or_create_dummy()
self.event = self.meta.event
self.person, unused = Person.get_or_create_dummy()
示例2: test_event_adminship
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def test_event_adminship(self):
person, unused = Person.get_or_create_dummy(superuser=False)
labour_event_meta, unused = LabourEventMeta.get_or_create_dummy()
assert not labour_event_meta.is_user_admin(person.user)
labour_event_meta.admin_group.user_set.add(person.user)
assert labour_event_meta.is_user_admin(person.user)
示例3: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls):
from .email_alias_type import EmailAliasType
from core.models import Person
alias_type, unused = EmailAliasType.get_or_create_dummy()
person, unused = Person.get_or_create_dummy()
return cls.objects.get_or_create(
type=alias_type,
person=person,
)
示例4: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls):
from core.models import Person
from labour.models import PersonnelClass
person, unused = Person.get_or_create_dummy()
personnel_class, unused = PersonnelClass.get_or_create_dummy()
return cls.objects.get_or_create(
person=person,
personnel_class=personnel_class,
)
示例5: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls):
from core.models import Person, Event
person, unused = Person.get_or_create_dummy()
event, unused = Event.get_or_create_dummy()
signup, created = Signup.objects.get_or_create(person=person, event=event)
extra = signup.signup_extra
extra.save()
return signup, created
示例6: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls):
from core.models import Person
from .team import Team
team, unused = Team.get_or_create_dummy()
person, unused = Person.get_or_create_dummy()
return cls.objects.get_or_create(
team=team,
person=person,
)
示例7: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls, programme=None):
from core.models import Person
from .role import Role
person, unused = Person.get_or_create_dummy()
role, unused = Role.get_or_create_dummy()
if programme is None:
programme, unused = Programme.get_or_create_dummy()
ProgrammeRole.objects.get_or_create(
person=person,
programme=programme,
role=role,
)
示例8: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls, entry_type=None, **kwargs):
from .entry_type_metadata import EntryTypeMetadata
from core.models import Person
if entry_type is None:
entry_type, unused = EntryTypeMetadata.get_or_create_dummy()
entry_type = entry_type.name
person, unused = Person.get_or_create_dummy()
attrs = dict(
entry_type=entry_type,
user=person.user,
)
attrs.update(kwargs)
return cls.objects.get_or_create(**attrs)
示例9: handle
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def handle(*args, **options):
if settings.DEBUG:
person, unused = Person.get_or_create_dummy()
Application.objects.get_or_create(
client_id='kompassi_insecure_test_client_id',
defaults=dict(
user=person.user,
redirect_uris='\n'.join([
'http://ssoexample.dev:8001/oauth2/callback',
'http://infokala.dev:8001/oauth2/callback',
'http://tracontent.dev:8001/oauth2/callback',
]),
client_type='confidential', # hah
authorization_grant_type='authorization-code',
client_secret='kompassi_insecure_test_client_secret',
name='Insecure test application',
)
)
示例10: test_qualifications
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def test_qualifications(self):
person, unused = Person.get_or_create_dummy()
qualification1, qualification2 = Qualification.get_or_create_dummies()
jc1, jc2 = JobCategory.get_or_create_dummies()
jc1.required_qualifications.add(qualification1)
assert not jc1.is_person_qualified(person)
assert jc2.is_person_qualified(person)
person.personqualification_set.create(qualification=qualification2)
assert not jc1.is_person_qualified(person)
assert jc2.is_person_qualified(person)
person.personqualification_set.create(qualification=qualification1)
assert jc1.is_person_qualified(person)
assert jc2.is_person_qualified(person)
示例11: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls, accepted=False):
from core.models import Person, Event
from .job_category import JobCategory
person, unused = Person.get_or_create_dummy()
event, unused = Event.get_or_create_dummy()
job_category, unused = JobCategory.get_or_create_dummy()
signup, created = Signup.objects.get_or_create(person=person, event=event)
if created:
signup.job_categories.set([job_category])
if accepted:
signup.job_categories_accepted.set(signup.job_categories.all())
signup.personnel_classes.add(signup.job_categories.first().personnel_classes.first())
signup.state = 'accepted'
signup.save()
signup.apply_state()
return signup, created
示例12: test_card_number
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def test_card_number(self):
"""
Tests that only well-formed JV card numbers are accepted.
"""
person, unused = Person.get_or_create_dummy()
qualification = Qualification.create_dummy()
personqualification = PersonQualification.objects.create(
person=person,
qualification=qualification,
)
today = date.today()
valid_examples = [
'8330/J1234/09',
'8520/J0000/13',
]
for valid_example in valid_examples:
JVKortti(
personqualification=personqualification,
card_number=valid_example,
expiration_date=today
).full_clean()
invalid_examples = [
'lol',
# '8330/J1234/0', # need more lax validation due to new cards having a new format
None,
''
]
for invalid_example in invalid_examples:
invalid = JVKortti(
personqualification=personqualification,
card_number=invalid_example,
expiration_date=today
)
self.assertRaises(ValidationError, lambda: invalid.full_clean())
示例13: get_or_create_dummy
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def get_or_create_dummy(cls, programme=None, role=None):
from core.models import Person
from .role import Role
from .programme import Programme
person, unused = Person.get_or_create_dummy()
if role is None:
role, unused = Role.get_or_create_dummy()
if programme is None:
programme, unused = Programme.get_or_create_dummy()
programme_role, created = ProgrammeRole.objects.get_or_create(
person=person,
programme=programme,
defaults=dict(
role=role,
)
)
programme.apply_state()
return programme_role, created
示例14: setup_labour
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def setup_labour(self):
from core.models import Person, Event
from core.utils import slugify
from labour.models import (
AlternativeSignupForm,
JobCategory,
LabourEventMeta,
PersonnelClass,
Qualification,
Survey,
)
from ...models import SignupExtra, SpecialDiet
from django.contrib.contenttypes.models import ContentType
labour_admin_group, = LabourEventMeta.get_or_create_groups(self.event, ['admins'])
if self.test:
person, unused = Person.get_or_create_dummy()
labour_admin_group.user_set.add(person.user)
content_type = ContentType.objects.get_for_model(SignupExtra)
labour_event_meta_defaults = dict(
signup_extra_content_type=content_type,
work_begins=datetime(2019, 2, 15, 8, 0, tzinfo=self.tz),
work_ends=datetime(2019, 2, 17, 21, 0, tzinfo=self.tz),
admin_group=labour_admin_group,
contact_email='Desuconin työvoimavastaava <[email protected]>',
)
if self.test:
t = now()
labour_event_meta_defaults.update(
registration_opens=t - timedelta(days=60),
registration_closes=t + timedelta(days=60),
)
labour_event_meta, unused = LabourEventMeta.objects.get_or_create(
event=self.event,
defaults=labour_event_meta_defaults,
)
for pc_name, pc_slug, pc_app_label in [
('Vastaava', 'vastaava', 'labour'),
('Vuorovastaava', 'vuorovastaava', 'labour'),
('Työvoima', 'tyovoima', 'labour'),
('Ohjelmanjärjestäjä', 'ohjelma', 'programme'),
('Guest of Honour', 'goh', 'programme'),
('Media', 'media', 'badges'),
('Myyjä', 'myyja', 'badges'),
('Vieras', 'vieras', 'badges'),
]:
personnel_class, created = PersonnelClass.objects.get_or_create(
event=self.event,
slug=pc_slug,
defaults=dict(
name=pc_name,
app_label=pc_app_label,
priority=self.get_ordering_number(),
),
)
tyovoima = PersonnelClass.objects.get(event=self.event, slug='tyovoima')
vastaava = PersonnelClass.objects.get(event=self.event, slug='vastaava')
if not JobCategory.objects.filter(event=self.event).exists():
JobCategory.copy_from_event(
source_event=Event.objects.get(slug='desucon2018'),
target_event=self.event,
)
for name in ['Vastaava']:
JobCategory.objects.filter(event=self.event, name=name).update(public=False)
for jc_name, qualification_name in [
('Järjestyksenvalvoja', 'JV-kortti'),
]:
jc = JobCategory.objects.get(event=self.event, name=jc_name)
qual = Qualification.objects.get(name=qualification_name)
jc.required_qualifications.set([qual])
labour_event_meta.create_groups()
organizer_form, unused = AlternativeSignupForm.objects.get_or_create(
event=self.event,
slug='vastaava',
defaults=dict(
title='Vastaavan ilmoittautumislomake',
signup_form_class_path='events.frostbite2019.forms:OrganizerSignupForm',
signup_extra_form_class_path='events.frostbite2019.forms:OrganizerSignupExtraForm',
active_from=datetime(2018, 9, 16, 0, 0, 0, tzinfo=self.tz),
active_until=self.event.start_time,
),
)
if organizer_form.active_until is None:
organizer_form.active_until = self.event.start_time
organizer_form.save()
#.........这里部分代码省略.........
示例15: setup_labour
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import get_or_create_dummy [as 别名]
def setup_labour(self):
from core.models import Person
from core.utils import slugify
from labour.models import (
AlternativeSignupForm,
JobCategory,
LabourEventMeta,
PersonnelClass,
Qualification,
)
from ...models import SignupExtra, SpecialDiet
from django.contrib.contenttypes.models import ContentType
labour_admin_group, = LabourEventMeta.get_or_create_groups(self.event, ['admins'])
if self.test:
person, unused = Person.get_or_create_dummy()
labour_admin_group.user_set.add(person.user)
content_type = ContentType.objects.get_for_model(SignupExtra)
labour_event_meta_defaults = dict(
signup_extra_content_type=content_type,
work_begins=datetime(2018, 1, 26, 8, 0, tzinfo=self.tz),
work_ends=datetime(2018, 6, 28, 21, 0, tzinfo=self.tz),
admin_group=labour_admin_group,
contact_email='Desuconin työvoimavastaava <[email protected]>',
)
if self.test:
t = now()
labour_event_meta_defaults.update(
registration_opens=t - timedelta(days=60),
registration_closes=t + timedelta(days=60),
)
labour_event_meta, unused = LabourEventMeta.objects.get_or_create(
event=self.event,
defaults=labour_event_meta_defaults,
)
for pc_name, pc_slug, pc_app_label in [
('Vastaava', 'vastaava', 'labour'),
('Vuorovastaava', 'vuorovastaava', 'labour'),
('Työvoima', 'tyovoima', 'labour'),
('Ohjelmanjärjestäjä', 'ohjelma', 'programme'),
('Guest of Honour', 'goh', 'programme'),
('Media', 'media', 'badges'),
('Myyjä', 'myyja', 'badges'),
('Vieras', 'vieras', 'badges'),
]:
personnel_class, created = PersonnelClass.objects.get_or_create(
event=self.event,
slug=pc_slug,
defaults=dict(
name=pc_name,
app_label=pc_app_label,
priority=self.get_ordering_number(),
),
)
tyovoima = PersonnelClass.objects.get(event=self.event, slug='tyovoima')
vastaava = PersonnelClass.objects.get(event=self.event, slug='vastaava')
for name, description, pcs in [
(
'Vastaava',
'Tapahtuman järjestelytoimikunnan jäsen eli vastaava',
[vastaava]
),
(
'Järjestyksenvalvoja',
'Kävijöiden turvallisuuden valvominen conipaikalla ja yömajoituksessa. Edellyttää voimassa olevaa '
'JV-korttia ja asiakaspalveluasennetta. HUOM! Et voi valita tätä tehtävää hakemukseesi, ellet ole '
'täyttänyt tietoihisi JV-kortin numeroa (oikealta ylhäältä oma nimesi > Pätevyydet).',
[tyovoima]
),
]:
job_category, created = JobCategory.objects.get_or_create(
event=self.event,
slug=slugify(name),
defaults=dict(
name=name,
description=description,
)
)
if created:
job_category.personnel_classes.set(pcs)
for name in ['Vastaava']:
JobCategory.objects.filter(event=self.event, name=name).update(public=False)
for jc_name, qualification_name in [
('Järjestyksenvalvoja', 'JV-kortti'),
]:
jc = JobCategory.objects.get(event=self.event, name=jc_name)
qual = Qualification.objects.get(name=qualification_name)
#.........这里部分代码省略.........