Ejemplo n.º 1
0
def create_status(name=None, slug=None, is_default=True, requires_review=True):

    if name is None:
        name = 'status_%04d' % get_next_id(models.TestInstanceStatus.objects.order_by('id').last())
    if slug is None:
        slug = 'status_%04d' % get_next_id(models.TestInstanceStatus.objects.order_by('id').last())

    status = models.TestInstanceStatus(name=name, slug=slug, is_default=is_default, requires_review=requires_review)
    status.save()
    return status
Ejemplo n.º 2
0
def create_third_party(vendor=None, first_name=None, last_name=None):

    if vendor is None:
        vendor = qa_utils.create_vendor()
    if first_name is None:
        first_name = 'first_name_%04d' % get_next_id(
            models.ThirdParty.objects.order_by('id').last())
    if last_name is None:
        last_name = 'last_name_%04d' % get_next_id(
            models.ThirdParty.objects.order_by('id').last())

    tp, _ = models.ThirdParty.objects.get_or_create(vendor=vendor,
                                                    first_name=first_name,
                                                    last_name=last_name)

    return tp
Ejemplo n.º 3
0
def create_group(name=None):
    if name is None:
        name = 'group_%04d' % get_next_id(Group.objects.order_by('id').last())
    g = Group(name=name)
    g.save()
    g.permissions.add(Permission.objects.get(codename="add_testlistinstance"))
    return g
Ejemplo n.º 4
0
def create_service_event_template(name=None,
                                  service_type=None,
                                  service_area=None,
                                  problem_description="",
                                  work_description="",
                                  created_by=None):

    if name is None:
        name = 'name_%04d' % get_next_id(
            models.ServiceEventTemplate.objects.order_by('id').last())

    if created_by is None:
        created_by = qa_utils.create_user()

    template, _ = models.ServiceEventTemplate.objects.get_or_create(
        name=name,
        service_area=service_area,
        service_type=service_type,
        problem_description=problem_description,
        work_description=work_description,
        created_by=created_by,
        modified_by=created_by,
    )

    return template
Ejemplo n.º 5
0
def create_part(part_category=None,
                part_number=None,
                name='description',
                add_storage=False,
                quantity_min=0,
                quantity_current=1,
                alt_part_number=None):

    if part_category is None:
        part_category = create_part_category()
    if part_number is None:
        part_number = str(
            get_next_id(p_models.PartCategory.objects.order_by('id').last()))

    p, _ = p_models.Part.objects.get_or_create(
        part_category=part_category,
        part_number=part_number,
        name=name,
        quantity_min=quantity_min,
        quantity_current=quantity_current,
        alt_part_number=alt_part_number)

    if add_storage:
        s = create_storage()
        create_part_storage_collection(part=p,
                                       storage=s,
                                       quantity=quantity_current)
        p.save()

    return p
Ejemplo n.º 6
0
def create_vendor(name=None):

    if name is None:
        name = 'vendor_%04d' % get_next_id(Vendor.objects.order_by('id').last())

    v, _ = Vendor.objects.get_or_create(name=name)

    return v
Ejemplo n.º 7
0
def create_unit_type(name=None, vendor=None, model="model"):

    if name is None:
        name = 'unit_type_%04d' % get_next_id(UnitType.objects.order_by('id').last())
    if vendor is None:
        vendor = create_vendor()
    ut, _ = UnitType.objects.get_or_create(name=name, vendor=vendor, model=model)
    ut.save()
    return ut
Ejemplo n.º 8
0
def create_service_area(name=None):

    if name is None:
        name = 'service_area_%04d' % get_next_id(
            models.ServiceArea.objects.order_by('id').last())

    sa, _ = models.ServiceArea.objects.get_or_create(name=name)

    return sa
Ejemplo n.º 9
0
def create_supplier(name=None):

    if name is None:
        name = 'supplier_%04d' % get_next_id(
            p_models.Supplier.objects.order_by('id').last())

    s, _ = p_models.Supplier.objects.get_or_create(name=name)

    return s
Ejemplo n.º 10
0
def create_part_category(name=None):

    if name is None:
        name = 'part_category_%04d' % get_next_id(
            p_models.PartCategory.objects.order_by('id').last())

    pc, _ = p_models.PartCategory.objects.get_or_create(name=name)

    return pc
Ejemplo n.º 11
0
def create_service_type(name=None, is_review_required=False, is_active=True):

    if name is None:
        name = 'service_type_%04d' % get_next_id(
            models.ServiceType.objects.order_by('id').last())

    st, _ = models.ServiceType.objects.get_or_create(
        name=name, is_review_required=is_review_required, is_active=is_active)

    return st
Ejemplo n.º 12
0
def create_site(name=None):

    if name is None:
        name = 'site_%04d' % get_next_id(
            u_models.Site.objects.order_by('id').last())

    slug = slugify(name)
    s, _ = u_models.Site.objects.get_or_create(name=name, slug=slug)

    return s
Ejemplo n.º 13
0
def create_group_linker(group=None, name=None):

    if group is None:
        group = create_group()
    if name is None:
        name = 'group_linker_%04d' % get_next_id(
            models.GroupLinker.objects.order_by('id').last())

    gl, _ = models.GroupLinker.objects.get_or_create(group=group, name=name)

    return gl
Ejemplo n.º 14
0
def create_room(site=None, name=None):

    if name is None:
        name = 'room_%04d' % get_next_id(
            p_models.Room.objects.order_by('id').last())
    if site is None:
        site = create_site()

    r, _ = p_models.Room.objects.get_or_create(name=name, site=site)

    return r
Ejemplo n.º 15
0
def create_test_list(name=None):

    if name is None:
        name = 'test_list_%04d' % get_next_id(models.TestList.objects.order_by('id').last())
    user = create_user()
    test_list = models.TestList(
        name=name,
        slug=name,
        description="desc",
        created_by=user,
        modified_by=user,
    )
    test_list.save()
    return test_list
Ejemplo n.º 16
0
def create_unit(name=None, number=None, tipe=None, site=None):

    if name is None:
        name = 'unit_%04d' % get_next_id(models.Unit.objects.order_by('id').last())
    if number is None:
        last = models.Unit.objects.order_by('number').last()
        number = last.number + 1 if last else 0
    if tipe is None:
        tipe = create_unit_type()

    u = Unit(name=name, number=number, date_acceptance=timezone.now(), type=tipe, is_serviceable=True, site=site)
    u.save()
    u.modalities.add(create_modality())
    return u
Ejemplo n.º 17
0
def create_service_event_status(name=None,
                                is_default=False,
                                is_review_required=True,
                                rts_qa_must_be_reviewed=False,
                                colour=settings.DEFAULT_COLOURS[0]):

    if name is None:
        name = 'service_event_status_%04d' % get_next_id(
            models.ServiceEventStatus.objects.order_by('id').last())

    ses, _ = models.ServiceEventStatus.objects.get_or_create(
        name=name,
        is_default=is_default,
        is_review_required=is_review_required,
        rts_qa_must_be_reviewed=rts_qa_must_be_reviewed,
        colour=colour)

    return ses
Ejemplo n.º 18
0
def create_frequency(name=None, slug=None, interval=1, window_end=1, save=True):
    if name is None or slug is None:
        name = 'frequency_%04d' % get_next_id(models.Frequency.objects.order_by('id').last())
        slug = name

    rule = recurrence.Rule(freq=recurrence.DAILY, interval=interval)

    f = models.Frequency(
        name=name,
        slug=slug,
        recurrences=recurrence.Recurrence(
            rrules=[rule],
            dtstart=timezone.get_current_timezone().localize(timezone.datetime(2012, 1, 1)),
        ),
        window_start=None,
        window_end=window_end,
    )
    if save:
        f.save()
    return f
Ejemplo n.º 19
0
def create_cycle(test_lists=None, name=None):

    if name is None:
        name = 'test_list_cycle_%04d' % get_next_id(models.TestListCycle.objects.order_by('id').last())

    user = create_user()
    cycle = models.TestListCycle(
        name=name,
        slug=name,
        created_by=user,
        modified_by=user
    )
    cycle.save()
    if test_lists:
        for order, test_list in enumerate(test_lists):
            tlcm = models.TestListCycleMembership(
                test_list=test_list,
                cycle=cycle,
                order=order
            )
            tlcm.save()

    return cycle
Ejemplo n.º 20
0
def create_site(name=None):

    if name is None:
        name = 'site_%04d' % get_next_id(Site.objects.order_by('id').last())

    return Site.objects.create(name=name)