コード例 #1
0
def create_programs(output=True):
    """Create programs and services from the DEFAULT_PROGRAMS dictionary, reflecting actual P-P organization"""
    for program, services in DEFAULT_PROGRAMS.items():
        p = Program()
        p.name = program

        if p.name in HAS_QUEUE:
            p.has_queue = True
        else:
            p.has_queue = False
        p.full_clean()
        p.save()

        if output:
            print("Created program {}".format(p.name))

        for service in services:
            s = Service()
            s.name = service
            s.slug = f"{p.name}-{s.name}"

            s.available = random_bool()
            s.program = p
            s.full_clean()
            s.save()

            if output:
                print("Created {}: '{}'".format(p.name, s.slug))

        """ Create forms for the program """
        for _ in range(DEFAULT_NUMBER_FORMS):
            create_form(p)
コード例 #2
0
ファイル: seed.py プロジェクト: dhoshya/prevention-point
def create_programs(output=True):
    '''Create programs and services from the DEFAULT_PROGRAMS dictionary, reflecting actual P-P organization'''
    for program, services in DEFAULT_PROGRAMS.items():
      p = Program()
      p.name = program
      p.full_clean()
      p.save()

      if output:
          print("Created program {}". format(p.name))

      for service in services:
          s = Service()
          s.name = service
          s.program = p
          s.available = random_bool()
          s.full_clean()
          s.save()

          if output:
              print("Created {}: '{}'". format(p.name, s.name))