当前位置: 首页>>代码示例>>Python>>正文


Python recipe.foreign_key函数代码示例

本文整理汇总了Python中model_mommy.recipe.foreign_key函数的典型用法代码示例。如果您正苦于以下问题:Python foreign_key函数的具体用法?Python foreign_key怎么用?Python foreign_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了foreign_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUpClass

    def setUpClass(cls):
        # clear db
        models.User.objects.all().delete()
        models.Activity.objects.all().delete()

        cls.assertStrEqual = lambda cls, x, y: cls.assertEqual(str(x), str(y))

        employee = recipe.Recipe(models.Employee,
                                 id=1,
                                 first_name='Jan',
                                 last_name='Wójt')
        company = recipe.Recipe(models.CoffeeCompany,
                                id=2,
                                full_name='Kawa')
        activity1 = recipe.Recipe(models.Activity,
                                  id=1,
                                  creator=recipe.foreign_key(employee),
                                  target=recipe.foreign_key(company),
                                  content='Jan Wójt drinked coffee from Kawa')
        activity2 = recipe.Recipe(models.Activity,
                                  id=2,
                                  creator=recipe.foreign_key(company),
                                  target=recipe.foreign_key(employee),
                                  content='Kawa delivered product to Jan Wójt')

        employee.make()
        company.make()
        activity1.make()
        activity2.make()
开发者ID:macie,项目名称:coffee,代码行数:29,代码来源:test_models.py

示例2: test_returns_a_callable

 def test_returns_a_callable(self):
     number_recipe = Recipe(DummyNumbersModel,
         float_field = 1.6
     )
     method = foreign_key(number_recipe)
     self.assertTrue(callable(method))
     self.assertTrue(method.im_self, number_recipe)
开发者ID:willemallan,项目名称:model_mommy,代码行数:7,代码来源:test_recipes.py

示例3: test_prepare_recipe_with_foreign_key

    def test_prepare_recipe_with_foreign_key(self):
        person_recipe = Recipe(Person, name='John Doe')
        dog_recipe = Recipe(Dog,
            owner=foreign_key(person_recipe),
        )
        dog = dog_recipe.prepare()

        self.assertIsNone(dog.id)
        self.assertIsNone(dog.owner.id)
开发者ID:berinhard,项目名称:model_mommy,代码行数:9,代码来源:test_recipes.py

示例4: Recipe

    pension=MoneyInterval('per_month', pennies=0),
    other_income=MoneyInterval('per_week', pennies=2200)
)
savings = Recipe(Savings)
deductions = Recipe(Deductions,
                    income_tax = MoneyInterval('per_week', pennies=2200),
                    national_insurance = MoneyInterval('per_4week', pennies=2200),
                    maintenance = MoneyInterval('per_year', pennies=2200),
                    childcare = MoneyInterval('per_week', pennies=2200),
                    mortgage = MoneyInterval('per_week', pennies=2200),
                    rent = MoneyInterval('per_week', pennies=2200)
                    )

person = Recipe(Person)
full_person = Recipe(Person,
    income=foreign_key(income),
    savings=foreign_key(savings),
    deductions=foreign_key(deductions)
)

eligibility_check = Recipe(EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5, dependants_old=6,
    you=foreign_key(person),
    partner=foreign_key(person)
)

eligibility_check_yes = Recipe(EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5, dependants_old=6,
    you=foreign_key(person),
开发者ID:doismellburning,项目名称:cla_backend,代码行数:31,代码来源:mommy_recipes.py

示例5: Recipe

    os.path.join(CUR_DIR, 'kenya_boundary.geojson'))


country_boundary_recipe = Recipe(
    WorldBorder,
    mpoly=_get_mpoly_from_geom(KENYA_BORDER[0].get_geoms()[0])
)


county_recipe = Recipe(
    County
)

county_boundary_recipe = Recipe(
    CountyBoundary,
    area=foreign_key(county_recipe),
    mpoly=_get_mpoly_from_geom(COUNTY_BORDER[0].get_geoms()[0])
)

constituency_recipe = Recipe(
    Constituency,
    county=foreign_key(county_recipe),
)

constituency_boundary_recipe = Recipe(
    ConstituencyBoundary,
    area=foreign_key(constituency_recipe),
    mpoly=_get_mpoly_from_geom(CONSTITUENCY_BORDER[0].get_geoms()[0])
)

开发者ID:FelixOngati,项目名称:mfl_api,代码行数:29,代码来源:mommy_recipes.py

示例6: Recipe

an **object-oriented** computer programming language commonly used to
create interactive effects within *web browsers*.''',
    ''''# Python

a *high-level* **general-purpose** _programming language_.''',
]

user = Recipe(
    User,
    email="[email protected]",
    is_active=True
)

category = Recipe(
    Category,
    title=seq('Category'),
    author=foreign_key(user),
    description=cycle('description'),
    _quantity=3
)

article = Recipe(
    Article,
    title=seq('Article'),
    author=foreign_key(user),
    category=foreign_key(category),
    content=cycle(definitions),
    _quantity=5
)
开发者ID:bazzite,项目名称:django-knowledgebase,代码行数:29,代码来源:mommy_recipes.py

示例7: Recipe

serial_numbers_by = Recipe(DummyDefaultFieldsModel,
    default_decimal_field = seq(Decimal('20.1'), increment_by=Decimal('2.4')),
    default_int_field = seq(10, increment_by=3),
    default_float_field = seq(1.23, increment_by=1.8)
)

serial_datetime = Recipe(DummyDefaultFieldsModel,
    default_date_field = seq(TEST_TIME.date(), timedelta(days=1)),
    default_date_time_field = seq(TEST_TIME, timedelta(hours=3)),
    default_time_field = seq(TEST_TIME.time(), timedelta(seconds=15))
)

dog = Recipe(Dog,
    breed = 'Pug',
    owner = foreign_key(person)
)

other_dog = Recipe(Dog,
    breed = 'Basset',
    owner = foreign_key('person')
)

other_dog_unicode = Recipe(Dog,
    breed = 'Basset',
    owner = foreign_key(u('person'))
)

dummy_unique_field = Recipe(DummyUniqueIntegerFieldModel,
    value = seq(10),
)
开发者ID:bruth,项目名称:model_mommy,代码行数:30,代码来源:mommy_recipes.py

示例8: Recipe

    name = 'San Francisco',
    slug = 'san-francisco',
    description = 'San Francisco',
    timezone = '-8.0',
    city = 'San Francisco',
    country = 'US',
    continent = 'NA',
    lat = '0',
    lon = '0',
    private = True
    )

location_mars = Recipe(
    Location,
    name = 'Mars',
    slug = 'mars',
    description = 'Mars',
    timezone = '-8.0',
    city = 'Mars',
    country = 'US',
    continent = 'NA',
    lat = '0',
    lon = '0',
    capacity = '100'
    )

registration = Recipe(
    Registration,
    location = foreign_key(location),
    # user = foreign_key(user),
    )
开发者ID:E-LLP,项目名称:39A,代码行数:31,代码来源:mommy_recipes.py

示例9: Recipe

REPORTER_NAME = 'rep'

public_ci = Recipe(CriticalIncident,
    incident = seq('Critical Incident '),
    public = True
)

published_incident = Recipe(PublishableIncident,
    publish = True,
    critical_incident__public = True,
    critical_incident__department__label = seq('Dept_'),
    critical_incident__department__reporter__user__username = seq(REPORTER_NAME),
)

translated_pi = Recipe(PublishableIncidentTranslation, 
    incident = seq('Published Incident '),
    master = foreign_key(published_incident)
)

reviewer = Recipe(Reviewer,
    user__username = seq('rev'),
    user__email = seq('[email protected]'),
)

reporter = Recipe(Reporter,
    user__username = seq(REPORTER_NAME))

department = Recipe(Department,
    label = seq('Dept_'),
    reporter__user__username = seq(REPORTER_NAME)
)
开发者ID:major-s,项目名称:labcirs,代码行数:31,代码来源:mommy_recipes.py

示例10: test_foreign_key_method_returns_a_recipe_foreign_key_object

 def test_foreign_key_method_returns_a_recipe_foreign_key_object(self):
     number_recipe = Recipe(DummyNumbersModel,
         float_field = 1.6
     )
     obj = foreign_key(number_recipe)
     self.assertIsInstance(obj, RecipeForeignKey)
开发者ID:lucassimon,项目名称:model_mommy,代码行数:6,代码来源:test_recipes.py

示例11: Recipe

from model_mommy.recipe import Recipe, seq, foreign_key
from ..models import Provider, ProviderAllocation, OutOfHoursRota, Staff, \
    Feedback, CSVUpload


provider = Recipe(Provider,
    name=seq('Name'),
)

staff = Recipe(Staff)

outofhoursrota = Recipe(OutOfHoursRota)

provider_allocation = Recipe(ProviderAllocation)

feedback = Recipe(Feedback, created_by=foreign_key(staff))

csvupload_determination = Recipe(CSVUpload,
                   body=[
                       u'2222222', u'0000', u'1A111A', u'A', u'Corgi',
                       u'01/01/1901', u'D', u'F', u'1', u'', u'', u'SW1A 1AA',
                       u'', u'SWAG', u'YOLO', u'', u'', u'', u'', u'', u'18',
                       u'99.5', u'', u'MOB', u'', u'', u'AAAA', u'', u'', u'',
                       u'NAR', u'', u'', u'TA'
                   ]
)


csvupload_case = \
    Recipe(CSVUpload,
           body=[
开发者ID:doismellburning,项目名称:cla_backend,代码行数:31,代码来源:mommy_recipes.py

示例12: Recipe

              email="[email protected]",
              )

# events; use defaults apart from dates
# override when using recipes, eg. mommy.make_recipe('future_event', cost=10)

event_type_PC = Recipe(EventType, event_type="CL", subtype=seq("Pole level class"))
event_type_PP = Recipe(EventType, event_type="CL", subtype=seq("Pole practice"))
event_type_WS = Recipe(EventType, event_type="EV", subtype=seq("Workshop"))
event_type_OE = Recipe(EventType, event_type="EV", subtype=seq("Other event"))
event_type_OC = Recipe(EventType, event_type="CL", subtype=seq("Other class"))
event_type_RH = Recipe(EventType, event_type="RH", subtype=seq("Room hire"))

future_EV = Recipe(Event,
                      date=future,
                      event_type=foreign_key(event_type_OE))

future_WS = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_WS))

future_PC = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_PC))
future_PP = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_PP))
future_CL = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_OC))
future_RH = Recipe(Event,
开发者ID:judy2k,项目名称:pipsevents,代码行数:31,代码来源:mommy_recipes.py

示例13: Recipe

from model_mommy.recipe import Recipe, foreign_key

from ..models import ReasonForContacting, ReasonForContactingCategory

reasonforcontacting = Recipe(ReasonForContacting, _fill_optional=["user_agent", "referrer"])
reasonforcontacting_category = Recipe(
    ReasonForContactingCategory, reason_for_contacting=foreign_key(reasonforcontacting)
)
开发者ID:ministryofjustice,项目名称:cla_backend,代码行数:8,代码来源:mommy_recipes.py

示例14: Recipe

from django.contrib.auth.models import User

from kb.base import choices
from kb.models import Article, Category, Vote
from model_mommy.recipe import foreign_key, Recipe, related

person = Recipe(User)

draft_article = Recipe(Article,
                       title='Draft Article Title',
                       content='Draft Article Content',
                       publish_state=choices.PublishChoice.Draft,
                       created_by=foreign_key(person))

published_article = Recipe(Article,
                           title='Published Article Title',
                           content='Published Article Content',
                           publish_state=choices.PublishChoice.Published,
                           created_by=foreign_key(person))

category_without_articles = Recipe(Category,
                                   name='Category Without Articles Title',
                                   description='Category Without Articles Description')

category_with_articles = Recipe(Category,
                                name='Category With Articles Title',
                                description='Category With Articles Description',
                                articles=related('draft_article',
                                                 'published_article'))

vote = Recipe(Vote, article__content='Markdown')
开发者ID:eliostvs,项目名称:django-kb,代码行数:31,代码来源:mommy_recipes.py

示例15: Recipe

from model_mommy.recipe import Recipe, foreign_key, seq

from project.account.mommy_recipes import domain
from .models import EmailDomain, EmailUser, EmailForward, EmailAlias, CatchAll

email_domain = Recipe(EmailDomain,
                      domain=foreign_key(domain),
                      )

email_user = Recipe(EmailUser,
                    domain=foreign_key(email_domain),
                    )

email_forward = Recipe(EmailForward,
                       user=foreign_key(email_user),
                       )

email_alias = Recipe(EmailAlias,
                     user=foreign_key(email_user),
                     )

catch_all = Recipe(CatchAll,
                   domain=foreign_key(email_domain),
                   user=foreign_key(email_user),
                   )
开发者ID:voltgrid,项目名称:mailmanager,代码行数:25,代码来源:mommy_recipes.py


注:本文中的model_mommy.recipe.foreign_key函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。