예제 #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', ''))
예제 #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)
예제 #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', ''))
예제 #4
0
파일: views.py 프로젝트: YeWR/WeChatTicket
 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('')
예제 #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)
예제 #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
예제 #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)
예제 #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.')
예제 #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("请先登录")
예제 #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)
예제 #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)
예제 #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
예제 #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)
예제 #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")
예제 #15
0
 def handle(self, *args, **options):
     CustomWeChatView.update_menu()
     self.logger.info('Updated menu.')
예제 #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)
예제 #17
0
 def post(self):
     activities = []
     for i in self.input:
         act = Activity.objects.get(id=i)
         activities.append(act)
     CustomWeChatView.update_menu(activities)
예제 #18
0
 def post(self):
     activities = list()
     for id in self.input:
         activities.append(Activity.objects.get(id=id))
     CustomWeChatView.update_menu(activities)
예제 #19
0
 def handle(self, *args, **options):
     CustomWeChatView.update_menu()
예제 #20
0
 def post(self):
     ids = self.input
     CustomWeChatView.update_menu([Activity.objects.get(id=x) for x in ids])
예제 #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)