Example #1
0
    def abstractFormProcess(self, action, **kwargs):
        try:
            post_dict = dict(self.request.POST)
            dispatcher = super().populateDispatcher()

            if dispatcher.get(action):
                team_id = kwargs.pop('id', None)
                team = self.useAPI(self.base_class).editSelf(id=team_id)
            else:
                team = self.base_class()

            team.team_name = RequestFunctions.getSingleRequestObj(post_dict, 'team_name')
            team.team_school = RequestFunctions.getSingleRequestObj(post_dict, 'team_school')
            team.team_tag_id = RequestFunctions.getSingleRequestObj(post_dict, 'team_tag_id')
            team.team_status = RequestFunctions.getSingleRequestObj(post_dict, 'team_status')

            if not action == 'delete':
                team.save()

            LogFunctions.generateLog(
                self.request, 'admin', LogFunctions.makeLogQuery(
                    self.base_class, action.title(), id=team.id))

            if action == 'delete':
                team.delete()
        except Exception:
            print({"Error": "Cannot Process " + action.title() + " Request."})
 def login(self):
     post_dict = dict(self.request.POST)
     uemail = RequestFunctions.getSingleRequestObj(post_dict, "email")
     upwd = RequestFunctions.getSingleRequestObj(post_dict, "password")
     if uemail and upwd:
         u = ModelFunctions.getModelObject(Account, account_email=uemail)
         if u is None:
             raise Exception('User not found')
         else:
             u_pwd = u.account_password
             u_salt = u.account_salt
             verify_pwd = hashlib.sha224(
                 (upwd + u_salt).encode("utf-8")).hexdigest()
             if u_pwd == verify_pwd:
                 account_type = self.account_type_mapper(u.account_type)
                 if account_type in self.acceptable_type:
                     current_configuration = ConfigAPI(
                         self.request).getAll()[0]
                     self.request.session['uid'] = u.id
                     self.request.session['utype'] = account_type
                     self.request.session['panel_config'] = dict(
                         season=current_configuration.config_current_season)
                     LogFunctions.generateLog(
                         self.request, "system",
                         LogFunctions.makeLogQuery(Account,
                                                   'Login',
                                                   id=u.id))
                     return redirect(reverse('panel.index'))
                 else:
                     raise Exception('Insufficient Permission')
             else:
                 raise Exception('Wrong Credentials')
     else:
         raise Exception('Insufficient Parameters')
    def abstractFormProcess(self, action, **kwargs):
        try:
            post_dict = dict(self.request.POST)
            dispatcher = super().populateDispatcher()

            if dispatcher.get(action):
                event_team_id = kwargs.pop('id', None)
                event_team = self.useAPI(self.base_class).editSelf(id=event_team_id)
            else:
                event_team = self.base_class()

            event_team.event_team_id = RequestFunctions.getSingleRequestObj(post_dict, 'event_team_id')
            event_team.event_team_event_activity_id = RequestFunctions.getSingleRequestObj(
                post_dict, 'event_team_event_activity_id')
            event_team.event_team_member_group_id = [RequestFunctions.getSingleRequestObj(post_dict, name + "_result")
                                                     for name in self.search_name][0]

            if not action == 'delete':
                event_team.save()

            LogFunctions.generateLog(
                self.request, 'admin', LogFunctions.makeLogQuery(
                    self.base_class, action.title(), id=event_team.id))

            if action == 'delete':
                event_team.delete()
        except Exception:
            print({"Error": "Cannot Process " + action.title() + " Request."})
    def abstractFormProcess(self, action, **kwargs):
        try:
            post_dict = dict(self.request.POST)
            dispatcher = super().populateDispatcher()

            if dispatcher.get(action):
                member_group_id = kwargs.pop('id', None)
                member_group = self.useAPI(self.base_class).editSelf(id=member_group_id)
            else:
                member_group = self.base_class()

            member_group.member_group_school = RequestFunctions.getSingleRequestObj(post_dict, 'member_group_school')
            member_group.member_group_member_ids = [RequestFunctions.getSingleRequestObj(post_dict, name + "_result")
                                                    for name in self.search_name]
            if action == 'add':
                member_group.member_group_name = ModelFunctions.getModelObject(
                    self.assoc_class_school,
                    id=member_group.member_group_school
                ).school_name + ' - ' + RequestFunctions.getSingleRequestObj(
                    post_dict, 'member_group_name'
                )
            elif action == 'edit':
                member_group.member_group_name = RequestFunctions.getSingleRequestObj(post_dict, 'member_group_name')

            member_group.save()

            LogFunctions.generateLog(
                self.request, 'admin', LogFunctions.makeLogQuery(
                    self.base_class, action.title(), id=member_group.id))

            if action == 'delete':
                member_group.delete()
        except Exception:
            print({"Error": "Cannot Process " + action.title() + " Request."})
 def process(self, action, **kwargs):
     self.process_dispatcher.get(action)(**kwargs)
     LogFunctions.generateLog(
         request=self.request,
         log_type=AuthenticationMetaAPI(self.request).getAuthType(),
         message='Core Data App Process - App: {}, Action: {}, Base Class: {}'
         .format(self.app_name, action, self.base_class))
Example #6
0
 def updateEventStatus(self, event_id, event_status):
     event = self.editSelf(id=event_id)
     AuthFunctions.raise404Empty(event)
     event.event_status = event_status
     event.save()
     LogFunctions.generateLog(
         self.request, 'admin',
         LogFunctions.makeLogQuery(Event, 'Edit', id=event.id))
Example #7
0
 def deleteSelf(self, legacy=True, **kwargs):
     if legacy:
         result = ModelFunctions.getModelObject(self.base, **kwargs)
     else:
         result = ModelFunctions.filterModelObject(self.base, **kwargs)
     result = self.auth_class(self.request).authenticate(
         AuthenticationActionType.DELETE, result)
     LogFunctions.generateLog(
         self.request, self.context.authType,
         "{} {} with kwargs {}".format("DELETE", self.class_name, kwargs))
     return result
Example #8
0
 def createSelf(self, **kwargs):
     obj = self.base()
     for key, val in kwargs.items():
         setattr(obj, key, val)
     result = self.auth_class(self.request).authenticate(
         AuthenticationActionType.ADD, obj)
     AuthFunctions.raise404Empty(result)
     LogFunctions.generateLog(
         self.request, self.context.authType,
         "{} {} with kwargs {}".format("CREATE", self.class_name, kwargs))
     obj.save()
 def logout(self):
     if RequestFunctions.sessionChecker(self.request, 'uid', 'utype'):
         LogFunctions.generateLog(
             self.request, "system",
             LogFunctions.makeLogQuery(Account,
                                       'Logout',
                                       id=self.request.session['uid']))
         self.request.session.clear()
         AuthFunctions.default_session(self.request)
     else:
         raise Exception('User is not logged in')
     return redirect(reverse('permission.dispatch', args=['view']))
Example #10
0
 def addSelf(self, obj):
     if isinstance(obj, self.base):
         result = self.auth_class(self.request).authenticate(
             AuthenticationActionType.ADD, obj)
         AuthFunctions.raise404Empty(result)
         LogFunctions.generateLog(
             self.request, self.context.authType,
             "{} {} with kwargs {}".format("ADD", self.class_name,
                                           obj.__dict__))
         return result
     else:
         AuthFunctions.raise404Empty()
Example #11
0
    def abstractFormProcess(self, action, **kwargs):
        try:
            post_dict = dict(self.request.POST)
            dispatcher = super().populateDispatcher()

            if dispatcher.get(action):
                account_id = kwargs.pop('id', None)
                account = self.useAPI(self.base_class).editSelf(id=account_id)
                pwd = RequestFunctions.getSingleRequestObj(
                    post_dict, 'account_password')
                pwd_salt = account.account_salt
                if not (pwd == account.account_password):
                    hashpwd = hashlib.sha224(
                        (pwd + pwd_salt).encode("utf-8")).hexdigest()
                    account.account_password = hashpwd
            else:
                account = self.base_class()
                pwd_salt = ''.join(
                    random.choices(string.ascii_uppercase + string.digits,
                                   k=15))
                hashpwd = hashlib.sha224(
                    (RequestFunctions.getSingleRequestObj(
                        post_dict, 'account_password') +
                     pwd_salt).encode("utf-8")).hexdigest()
                account.account_salt = pwd_salt
                account.account_password = hashpwd

            account.account_type = RequestFunctions.getSingleRequestObj(
                post_dict, 'account_type')
            account.account_email = RequestFunctions.getSingleRequestObj(
                post_dict, 'account_email')
            account.account_status = RequestFunctions.getSingleRequestObj(
                post_dict, 'account_status')
            account.account_linked_id = RequestFunctions.getSingleRequestObj(
                post_dict, 'account_linked_id')

            if not action == 'delete':
                account.save()

            LogFunctions.generateLog(
                self.request, 'admin',
                LogFunctions.makeLogQuery(self.base_class,
                                          action.title(),
                                          id=account.id))

            if action == 'delete':
                account.delete()
        except Exception as e:
            print({
                "Error":
                "Cannot Process " + action.title() + " Request. " + str(e)
            })
Example #12
0
 def edit(key):
     event_activity = self.useAPI(self.base_class).editSelf(id=key)
     event_activity.event_activity_event_parent = int(
         [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[0] + "_result")][0])
     event_activity.event_activity_event_tag = int(
         [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[1] + "_result")][0])
     event_activity.event_activity_name = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_name')
     event_activity.event_activity_order = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_order')
     event_activity.event_activity_result = MiscFunctions.jsonLoadCatch(
         RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_result'))
     event_activity.event_activity_type = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_type')
     event_activity.event_activity_note = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_note')
     event_activity.event_activity_status = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_status')
     event_activity.save()
     LogFunctions.generateLog(
         self.request, 'admin', LogFunctions.makeLogQuery(
             self.base_class, action.title(), id=event_activity.id))
    def abstractFormProcess(self, action, **kwargs):
        try:
            post_dict = dict(self.request.POST)
            dispatcher = super().populateDispatcher()

            if dispatcher.get(action):
                summary_id = kwargs.pop('id', None)
                summary = self.useAPI(self.base_class).editSelf(id=summary_id)
            else:
                summary = self.base_class()

            summary.summary_event_parent = [
                RequestFunctions.getSingleRequestObj(post_dict,
                                                     name + "_result")
                for name in self.search_name
            ][0]
            summary.summary_event_school = RequestFunctions.getSingleRequestObj(
                post_dict, 'summary_event_school')
            summary.summary_event_ranking = RequestFunctions.getSingleRequestObj(
                post_dict, 'summary_event_ranking')
            summary.summary_event_override_ranking = RequestFunctions.getSingleRequestObj(
                post_dict, 'summary_event_override_ranking')
            summary.summary_event_race_score = RequestFunctions.getSingleRequestObj(
                post_dict, 'summary_event_race_score')
            summary.summary_event_league_score = RequestFunctions.getSingleRequestObj(
                post_dict, 'summary_event_league_score')
            summary.summary_event_override_league_score = RequestFunctions.getSingleRequestObj(
                post_dict, 'summary_event_override_league_score')

            if not action == 'delete':
                summary.save()

            LogFunctions.generateLog(
                self.request, 'admin',
                LogFunctions.makeLogQuery(self.base_class,
                                          action.title(),
                                          id=summary.id))

            if action == 'delete':
                summary.delete()
        except Exception:
            print({"Error": "Cannot Process " + action.title() + " Request."})
Example #14
0
        def delete(key):
            event_api = self.useAPI(self.assoc_class_event)
            event_activity = self.useAPI(self.base_class).editSelf(id=key)
            event_team_links = self.useAPI(
                self.assoc_class_team_link
            ).filterSelf(event_team_event_activity_id=event_activity.id)

            for event_team_link in event_team_links:
                LogFunctions.generateLog(
                    self.request, 'admin', LogFunctions.makeLogQuery(
                        self.assoc_class_team_link, action.title(), id=event_team_link.id))
                event_team_link.delete()
            LogFunctions.generateLog(
                self.request, 'admin', LogFunctions.makeLogQuery(
                    self.base_class, action.title(), id=event_activity.id))
            event_activity.delete()

            event = event_api.getSelf(id=event_activity.event_activity_event_parent)
            event_type = int(event.event_type)
            event_team_num = int(event.event_team_number)
            event_rotation = event.event_rotation_detail
            event_tag = event_activity.event_activity_event_tag
            new_rotation = {}
            if event_type == 1:
                new_rotation = self.__fleetRotationUpdater(event_tag, event_team_num, 'delete', event_rotation)
            elif event_type == 2:
                new_rotation = self.__teamRotationUpdater()
            event.event_rotation_detail = new_rotation
            event.save()
            LogFunctions.generateLog(
                self.request, 'admin', LogFunctions.makeLogQuery(
                    self.assoc_class_event, action.title(), id=event.id))
Example #15
0
        def add():
            event_api = self.useAPI(self.assoc_class_event)
            event_activity = self.base_class()
            event_activity.event_activity_event_parent = int(
                [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[0] + "_result")][0])
            event_activity.event_activity_event_tag = int(
                [RequestFunctions.getSingleRequestObj(post_dict, self.search_name[1] + "_result")][0])
            event_activity.event_activity_name = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_name')
            event_activity.event_activity_order = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_order')
            event_activity.event_activity_result = MiscFunctions.jsonLoadCatch(
                RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_result'))
            event_activity.event_activity_type = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_type')
            event_activity.event_activity_note = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_note')
            event_activity.event_activity_status = RequestFunctions.getSingleRequestObj(post_dict, 'event_activity_status')
            event_activity.save()

            LogFunctions.generateLog(
                self.request, 'admin', LogFunctions.makeLogQuery(
                    self.base_class, action.title(), id=event_activity.id))

            teams = event_api.getEventCascadeTeams(event_activity.event_activity_event_parent)
            matching_teams = list(filter(lambda x: x.team_tag_id == event_activity.event_activity_event_tag, teams))
            for team in matching_teams:
                event_team = self.assoc_class_team_link()
                event_team.event_team_event_activity_id = event_activity.id
                event_team.event_team_id = team.id
                event_team.save()
                LogFunctions.generateLog(
                    self.request, 'admin', LogFunctions.makeLogQuery(
                        self.assoc_class_team_link, action.title(), id=event_team.id))

            event = event_api.getSelf(id=event_activity.event_activity_event_parent)
            event_type = int(event.event_type)
            event_team_num = int(event.event_team_number)
            event_rotation = event.event_rotation_detail
            event_tag = event_activity.event_activity_event_tag
            new_rotation = {}
            if event_type == 1:
                new_rotation = self.__fleetRotationUpdater(event_tag, event_team_num, 'add', event_rotation)
            elif event_type == 2:
                new_rotation = self.__teamRotationUpdater()
            event.event_rotation_detail = new_rotation
            event.save()
            LogFunctions.generateLog(
                self.request, 'admin', LogFunctions.makeLogQuery(
                    self.assoc_class_event, action.title(), id=event.id))
        def add():
            post_dict = dict(self.request.POST)

            event_type = RequestFunctions.getSinglePostObj(
                post_dict, 'event_type')
            event_class = RequestFunctions.getSinglePostObj(
                post_dict, 'event_class')
            event_name = RequestFunctions.getSinglePostObj(
                post_dict, 'event_name')
            event_status = RequestFunctions.getSinglePostObj(
                post_dict, 'event_status')
            event_description = RequestFunctions.getSinglePostObj(
                post_dict, 'event_description')
            event_location = RequestFunctions.getSinglePostObj(
                post_dict, 'event_location')
            event_season = RequestFunctions.getSinglePostObj(
                post_dict, 'event_season')
            event_region = RequestFunctions.getSinglePostObj(
                post_dict, 'event_region')
            event_host = RequestFunctions.getSinglePostObj(
                post_dict, 'event_host')
            event_school = RequestFunctions.getMultiplePostObj(
                post_dict, 'event_team')
            event_race_number = RequestFunctions.getSinglePostObj(
                post_dict, 'event_race_number')
            event_boat_rotation_name = RequestFunctions.getSinglePostObj(
                post_dict, 'event_boat_rotation_name')
            event_start_date = RequestFunctions.getSinglePostObj(
                post_dict, 'event_start_date')
            event_end_date = RequestFunctions.getSinglePostObj(
                post_dict, 'event_end_date')

            race_tag_dict = dict()
            team_activity_dict = dict()
            # event generation
            event_creation = self.base_class()
            event_creation.event_type = int(event_type)
            event_creation.event_class = int(event_class)
            event_creation.event_name = event_name
            event_creation.event_status = event_status
            event_creation.event_description = event_description
            event_creation.event_location = event_location
            event_creation.event_season = event_season
            event_creation.event_region = int(event_region)
            event_creation.event_host = int(event_host)
            event_creation.event_boat_rotation_name = event_boat_rotation_name
            event_creation.event_race_number = int(event_race_number)
            event_creation.event_start_date = event_start_date
            event_creation.event_end_date = event_end_date
            event_creation.event_team_number = len(event_school)
            event_creation.event_school_ids = event_school
            event_creation.event_rotation_detail = {}
            event_creation.save()

            # event tag generation
            for tag in self.event_race_tag:
                event_tag = self.assoc_class_tag()
                event_tag.event_tag_event_id = event_creation.id
                event_tag.event_tag_name = tag
                event_tag.save()
                race_tag_dict[tag] = event_tag.id
                LogFunctions.generateLog(
                    self.request, 'admin',
                    LogFunctions.makeLogQuery(self.assoc_class_tag,
                                              action.title(),
                                              id=event_tag.id))

            for school_id in event_school:
                # NOTE: not sure if using api here will cause error
                school = ModelFunctions.getModelObject(School, id=school_id)
                # summary generation
                summary = self.assoc_class_summary()
                summary.summary_event_parent = event_creation.id
                summary.summary_event_school = school_id
                summary.save()
                LogFunctions.generateLog(
                    self.request, 'admin',
                    LogFunctions.makeLogQuery(self.assoc_class_summary,
                                              action.title(),
                                              id=summary.id))
                # team generation
                for index, suffix in enumerate(self.event_team_name_suffix):
                    team = self.assoc_class_team()
                    team_name = str(
                        school.school_default_team_name) + ' ' + suffix
                    team.team_name = team_name
                    team.team_school = school_id
                    team.team_status = "active"
                    team.team_tag_id = list(race_tag_dict.values())[index]
                    team.save()
                    if self.event_race_tag[index] not in team_activity_dict:
                        team_activity_dict[self.event_race_tag[index]] = []
                    team_activity_dict[self.event_race_tag[index]].append(
                        team.id)
                    LogFunctions.generateLog(
                        self.request, 'admin',
                        LogFunctions.makeLogQuery(self.assoc_class_team,
                                                  action.title(),
                                                  id=team.id))
            for tag, tag_id in race_tag_dict.items():
                for race in range(event_creation.event_race_number):
                    # event activity generation
                    event_activity = self.assoc_class_activity()
                    event_activity.event_activity_event_parent = event_creation.id
                    event_activity.event_activity_event_tag = tag_id
                    event_activity.event_activity_name = tag + ' Race ' + str(
                        race + 1)
                    event_activity.event_activity_order = race + 1
                    event_activity.event_activity_result = dict()
                    event_activity.event_activity_note = ""
                    event_activity.event_activity_type = self.event_activity_type
                    event_activity.event_activity_status = "future"
                    event_activity.save()
                    LogFunctions.generateLog(
                        self.request, 'admin',
                        LogFunctions.makeLogQuery(self.assoc_class_activity,
                                                  action.title(),
                                                  id=event_activity.id))
                    for team_id in team_activity_dict[tag]:
                        # event team link generation
                        event_team = self.assoc_class_team_link()
                        event_team.event_team_event_activity_id = event_activity.id
                        event_team.event_team_id = team_id
                        event_team.save()
                        LogFunctions.generateLog(
                            self.request, 'admin',
                            LogFunctions.makeLogQuery(
                                self.assoc_class_team_link,
                                action.title(),
                                id=event_team.id))

            event_creation.event_rotation_detail = self.__rotationGenerator(
                race_tag_dict, team_activity_dict,
                event_creation.event_race_number,
                event_creation.event_team_number)
            event_creation.save()
            LogFunctions.generateLog(
                self.request, 'admin',
                LogFunctions.makeLogQuery(self.base_class,
                                          action.title(),
                                          id=event_creation.id))
Example #17
0
    def abstractFormProcess(self, action, **kwargs):
        try:
            if not action == 'edit':
                raise Exception(
                    'Trying to ' + action +
                    ' event in Logic-less Event Data Management Panel')

            post_dict = dict(self.request.POST)

            event_type = RequestFunctions.getSinglePostObj(
                post_dict, 'event_type')
            event_class = RequestFunctions.getSinglePostObj(
                post_dict, 'event_class')
            event_name = RequestFunctions.getSinglePostObj(
                post_dict, 'event_name')
            event_status = RequestFunctions.getSinglePostObj(
                post_dict, 'event_status')
            event_description = RequestFunctions.getSinglePostObj(
                post_dict, 'event_description')
            event_location = RequestFunctions.getSinglePostObj(
                post_dict, 'event_location')
            event_season = RequestFunctions.getSinglePostObj(
                post_dict, 'event_season')
            event_region = RequestFunctions.getSinglePostObj(
                post_dict, 'event_region')
            event_host = RequestFunctions.getSinglePostObj(
                post_dict, 'event_host')
            event_school = RequestFunctions.getMultiplePostObj(
                post_dict, 'event_team')
            event_race_number = RequestFunctions.getSinglePostObj(
                post_dict, 'event_race_number')
            event_boat_rotation_name = RequestFunctions.getSinglePostObj(
                post_dict, 'event_boat_rotation_name')
            event_rotation_detail = MiscFunctions.jsonLoadCatch(
                RequestFunctions.getSingleRequestObj(post_dict,
                                                     'event_rotation_detail'))
            event_start_date = RequestFunctions.getSingleRequestObj(
                post_dict, 'event_start_date')
            event_end_date = RequestFunctions.getSingleRequestObj(
                post_dict, 'event_end_date')

            dispatcher = super().populateDispatcher()
            if dispatcher.get(action):
                event_creation_id = kwargs.pop('id', None)
                event_creation = self.useAPI(
                    self.base_class).editSelf(id=event_creation_id)
            else:
                event_creation = self.base_class()

            # event generation
            event_creation.event_type = int(event_type)
            event_creation.event_class = int(event_class)
            event_creation.event_name = event_name
            event_creation.event_status = event_status
            event_creation.event_description = event_description
            event_creation.event_location = event_location
            event_creation.event_season = int(event_season)
            event_creation.event_region = int(event_region)
            event_creation.event_host = int(event_host)
            event_creation.event_race_number = int(event_race_number)
            event_creation.event_boat_rotation_name = event_boat_rotation_name
            event_creation.event_start_date = event_start_date
            event_creation.event_end_date = event_end_date
            event_creation.event_team_number = 0 if event_school is None else len(
                event_school)
            event_creation.event_school_ids = [] if event_school is None else event_school
            event_creation.event_rotation_detail = event_rotation_detail
            event_creation.save()

            if not action == 'edit':
                event_creation.save()

            LogFunctions.generateLog(
                self.request, 'admin',
                LogFunctions.makeLogQuery(self.base_class,
                                          action.title(),
                                          id=event_creation.id))

        except Exception as e:
            print({"Error": "Cannot Process " + action.title() + " Request."})
            print(e)
Example #18
0
 def actionEdit():
     element = get_object_or_404(currentClass, pk=element_id)
     form = self.view_dispatcher.get(self.form_path)["form"](self.request.POST, instance=element)
     temp = form.save()
     LogFunctions.generateLog(
         self.request, 'admin', LogFunctions.makeLogQuery(currentClass, action.title(), id=temp.id))
Example #19
0
 def actionAdd():
     form = self.view_dispatcher.get(self.form_path)["form"](self.request.POST)
     temp = form.save()
     LogFunctions.generateLog(
         self.request, 'admin', LogFunctions.makeLogQuery(currentClass, action.title(), id=temp.id))
Example #20
0
 def actionDelete():
     element = get_object_or_404(currentClass, pk=element_id)
     LogFunctions.generateLog(
         self.request, 'admin', LogFunctions.makeLogQuery(currentClass, action.title(), id=element.id))
     element.delete()
        def delete(key):
            event_api = self.useAPI(self.base_class)
            event_activity_api = self.useAPI(self.assoc_class_activity)
            summary_api = self.useAPI(self.assoc_class_summary)
            event_team_api = self.useAPI(self.assoc_class_team_link)
            event_tag_api = self.useAPI(self.assoc_class_tag)
            event = event_api.editSelf(id=key)
            event_activities = event_activity_api.filterSelf(
                event_activity_event_parent=event.id)
            event_summaries = summary_api.filterSelf(
                summary_event_parent=event.id)

            event_tags = event_tag_api.filterSelf(event_tag_event_id=event.id)
            event_teams = event_api.getEventCascadeTeams(event.id)
            event_team_links = [
                event_team_api.filterSelf(
                    event_team_event_activity_id=activity.id)
                for activity in event_activities
            ]

            for team in event_teams:
                LogFunctions.generateLog(
                    self.request, 'admin',
                    LogFunctions.makeLogQuery(self.assoc_class_team,
                                              action.title(),
                                              id=team.id))
                team.delete()
            for tag in event_tags:
                LogFunctions.generateLog(
                    self.request, 'admin',
                    LogFunctions.makeLogQuery(self.assoc_class_tag,
                                              action.title(),
                                              id=tag.id))
                tag.delete()
            for summary in event_summaries:
                LogFunctions.generateLog(
                    self.request, 'admin',
                    LogFunctions.makeLogQuery(self.assoc_class_summary,
                                              action.title(),
                                              id=summary.id))
                summary.delete()

            for activity in event_activities:
                LogFunctions.generateLog(
                    self.request, 'admin',
                    LogFunctions.makeLogQuery(self.assoc_class_activity,
                                              action.title(),
                                              id=activity.id))
                activity.delete()
            for team_links in event_team_links:
                for team_link in team_links:
                    LogFunctions.generateLog(
                        self.request, 'admin',
                        LogFunctions.makeLogQuery(self.assoc_class_team_link,
                                                  action.title(),
                                                  id=team_link.id))
                    team_link.delete()
            LogFunctions.generateLog(
                self.request, 'admin',
                LogFunctions.makeLogQuery(self.base_class,
                                          action.title(),
                                          id=event.id))
            event.delete()