def create_default_groups():
        """
        Automatically create groups in STRATUM_GROUPS
        """
        # Fisheries, Programs, Gear Types

        premade = [
            {
                'group': 16,
                'name': 'Non Catchshares',
                'group_type': 'Programs'
            },
            {
                'group': 17,
                'name': 'Catchshares',
                'group_type': 'Programs'
            },
            {
                'group': 18,
                'name': 'All',
                'group_type': 'Programs'
            },
        ]
        for g in premade:
            StratumGroups.create(**g)

        for prog in Programs.select():
            ProgramStratumGroupMtx.create(group=18, program=prog.program)
            if 'Catch Shares' == prog.program_name:
                ProgramStratumGroupMtx.create(group=17, program=prog.program)
            else:
                ProgramStratumGroupMtx.create(group=16, program=prog.program)
Beispiel #2
0
    def _get_programs_orm(self, rebuild=False):
        """
        Get programs from database via ORM, store DB keys
        """
        if self._programs is not None and not rebuild:  # only build this once
            return

        self._programs = list()

        fish_q = Programs.select()
        for fishery in fish_q:
            self._programs.append(fishery.program_name)
        self._programs = sorted(set(self._programs))  # Remove Duplicates + Sort Alphabetically