Example #1
0
 def handle(self, *args, **options):
     CustomWeChatView.update_menu()
     act_btns = CustomWeChatView.get_book_btn().get('sub_button', list())
     self.logger.info('Updated %d activities', len(act_btns))
     self.logger.info('=' * 32)
     for idx, act in enumerate(act_btns):
         self.logger.info('%d. %s (%s)', idx, act.get('name', ''),
                          act.get('key', ''))
Example #2
0
 def post(self):
     if not self.request.user:
         raise ValidateError("you are logout")
     ides = self.input
     array = []
     for each_id in ides:
         act = Activity.objects.get(id=each_id)
         array.append(act)
     CustomWeChatView.update_menu(array)
Example #3
0
 def handle(self, *args, **options):
     CustomWeChatView.update_menu(Activity.objects.filter(
         status=Activity.STATUS_PUBLISHED, book_end__gt=timezone.now()
     ).order_by('book_end'))
     act_btns = CustomWeChatView.get_book_btn().get('sub_button', list())
     self.logger.info('Updated %d activities', len(act_btns))
     self.logger.info('=' * 32)
     for idx, act in enumerate(act_btns):
         self.logger.info('%d. %s (%s)', idx, act.get('name', ''), act.get('key', ''))
Example #4
0
 def post(self):
     if self.request.user.is_authenticated():
         list = []
         for item in self.input:
             acti = Activity.objects.filter(id=item).first()
             list.append(acti)
         CustomWeChatView.update_menu(list)
         pass
     else:
         raise LoginError('')
Example #5
0
 def post(self):
     if not self.request.user.is_authenticated():
         raise ValidateError('User has not logged in.')
     activityList = []
     for activity_id in self.input:
         activity = Activity.get_by_id(activity_id)
         activity.status = Activity.STATUS_PUBLISHED
         activity.save()
         activityList.append(activity)
     CustomWeChatView.update_menu(activityList)
Example #6
0
 def post(self):
     if isinstance(self.input, list) == False:
         raise InputError('')
     input_list = self.input
     act_list = []
     for update_id in input_list:
         act = Activity.objects.get(id=update_id)
         act_list.append(act)
     CustomWeChatView.update_menu(act_list)
     return None
Example #7
0
 def post(self):
     activity_list = []
     for iid in self.input:
         try:
             activity = Activity.objects.get(id=iid)
         except Activity.DoesNotExist:
             raise NotExistError(
                 "activity menu error: (post) activity not found")
         activity_list.append(activity)
     CustomWeChatView.update_menu(activity_list)
Example #8
0
    def post(self):
        if not self.request.user.is_authenticated():
            raise ValidateError('Sorry, you are not logged in.')
        # self.check_input('id')
        try:
            in_act = self.input
            activities = Activity.objects.filter(id__in=in_act)
            CustomWeChatView.update_menu(activities)

        except Exception as e:
            raise MenuError('Failed to update menu.')
Example #9
0
    def post(self):
        user = self.request.user
        if user.is_authenticated:
            activities = []
            for id in self.input:
                activity = Activity.objects.get(id=id)
                activities.append(activity)
            CustomWeChatView.update_menu(activities)

        else:
            raise ValidateError("请先登录")
Example #10
0
    def post(self):
        data = json.loads(self.request.body.decode('utf-8'))
        idList = data['ids']
        nameList = data['names']

        activities = []
        for idx, id in enumerate(idList):
            activity = Activity()
            activity.id = id
            activity.name = nameList[idx]
            activities.append(activity)

        CustomWeChatView.update_menu(activities)
Example #11
0
    def post(self):
        if not self.request.user.is_authenticated():
            raise LogicError('not authenticate')
        ret_activities = []
        if not self.input:
            CustomWeChatView.update_menu(ret_activities)
        for _id in self.input:
            try:
                activity = Activity.objects.get(id=_id)
            except Activity.DoesNotExist:
                raise LogicError('activity not exist')
            ret_activities.append(activity)

        CustomWeChatView.update_menu(ret_activities)
Example #12
0
 def post(self):
     """
             input:  活动id数组
                     需要登录
     """
     if not self.request.user.is_authenticated():
         raise ValidateError("admin-user not login!")
     else:
         result = []
         activity_id_list = self.input
         for act_id in activity_id_list:
             act = Activity.get_by_id(act_id)
             result.append(act)
     CustomWeChatView.update_menu(result)
     return
Example #13
0
 def post(self):
     if not self.request.user.is_authenticated():
         raise ValidateError("Please login!")
     idList = self.input
     for i in Activity.objects.filter(status=Activity.STATUS_PUBLISHED):
         i.status = 0
     activityList = []
     for id in idList:
         try:
             act = Activity.objects.get(id=id)
             act.status = 1
             act.save()
             activityList.append(act)
         except:
             raise ValidateError("no such activity")
     CustomWeChatView.update_menu(activityList)
Example #14
0
    def post(self):

        if not self.request.user.is_authenticated():
            raise ValidateError("not login")

        try:
            activity_id_list = self.input
            MenuIdList.set_menu(activity_id_list)
            activity_list = []
            for id in activity_id_list:
                activity = Activity.objects.get(id=id)
                activity_list.append(activity)
            CustomWeChatView.update_menu(activity_list)

        except Exception as e:
            raise MenuError("update menu failed")
Example #15
0
 def handle(self, *args, **options):
     CustomWeChatView.update_menu()
     self.logger.info('Updated menu.')
Example #16
0
 def post(self):
     if self.request.user.is_authenticated():
         activities = [Activity.objects.get(id=id) for id in self.input]
         CustomWeChatView.update_menu(activities)
Example #17
0
 def post(self):
     activities = []
     for i in self.input:
         act = Activity.objects.get(id=i)
         activities.append(act)
     CustomWeChatView.update_menu(activities)
Example #18
0
 def post(self):
     activities = list()
     for id in self.input:
         activities.append(Activity.objects.get(id=id))
     CustomWeChatView.update_menu(activities)
Example #19
0
 def handle(self, *args, **options):
     CustomWeChatView.update_menu()
Example #20
0
 def post(self):
     ids = self.input
     CustomWeChatView.update_menu([Activity.objects.get(id=x) for x in ids])
Example #21
0
 def post(self):
     activity_list = []
     for i in self.input:
         activity = Activity.objects.get(id=i)
         activity_list.append(activity)
     CustomWeChatView.update_menu(activity_list)