Exemplo n.º 1
0
def create_restriction(group, external_id, name):
    model = models.Restriction.objects.create(group=group,
                                              external_id=external_id,
                                              name=name)
    restriction = objects.Restriction.from_model(model)
    restrictions_storage.add_item(restriction.id, restriction)
    restrictions_storage.update_version()
    return restriction
Exemplo n.º 2
0
def sync_restriction(group, external_id, name):
    restriction = restrictions_storage.get_restriction(group, external_id)

    if restriction is None:
        return create_restriction(group, external_id, name)

    restriction.name = name
    models.Restriction.objects.filter(id=restriction.id).update(name=name)
    restrictions_storage.update_version()

    return restriction
Exemplo n.º 3
0
def sync_restriction(group, external_id, name):
    restriction = restrictions_storage.get_restriction(group, external_id)

    if restriction is None:
        return create_restriction(group, external_id, name)

    restriction.name = name
    models.Restriction.objects.filter(id=restriction.id).update(name=name)
    restrictions_storage.update_version()

    return restriction
Exemplo n.º 4
0
def create_restriction(group, external_id, name):
    model = models.Restriction.objects.create(group=group, external_id=external_id, name=name)
    restriction = objects.Restriction.from_model(model)
    restrictions_storage.add_item(restriction.id, restriction)
    restrictions_storage.update_version()
    return restriction