예제 #1
0
 def get(self):
     #self.check_input('activityId')
     nid = self.request.GET.get('nid')
     if nid is not None:
         nid = self.request.GET.get('nid')
         #program_list = Programe.selectByActivity(Activity.selectById(self.input['activityId']))
         program_list = Programe.selectByActivity(Activity.selectById(nid))
         activityId = nid
     else:
         testtt = Activity.selectById(self.request.COOKIES['activityId'])
         program_list = Programe.selectByActivity(
             Activity.selectById(self.request.COOKIES['activityId']))
         activityId = self.request.COOKIES['activityId']
     show_list = []
     num = 0
     for program in program_list:
         num = num + 1
         show_list.append({
             'id': program.id,
             'name': program.name,
             'sequence': program.sequence,
             #'actor': program.actor
         })
     n = len(show_list)
     for j in range(0, n - 1):
         for i in range(0, n - 1 - j):
             if show_list[i]['sequence'] > show_list[i + 1]['sequence']:
                 show_list[i], show_list[i + 1] = show_list[i +
                                                            1], show_list[i]
     return {
         'view': 25,
         'list': show_list,
         'activityId': activityId,
         'num': num
     }
예제 #2
0
    def post(self):
        if not self.request.user.is_authenticated():
            raise ValidateError("Please Login First!")
        if 'create' in self.request.POST:
            self.check_input('name', 'description', 'actors')
            sequence = str(int(self.request.COOKIES['ProgrameNum']) + 1)
            Programe.insertPrograme(
                Activity.selectById(self.request.COOKIES['activityId']),
                self.input['name'], self.input['description'], sequence,
                self.input['actors'])
            '''if not Activity.objects.filter(self.input['name']):
                raise LogicError('fail creat pragram')
            else:
                return {'view': 6}'''

            return {'view': 6}

        if 'return' in self.request.POST:
            return {'view': 6}
예제 #3
0
	def get(self):
		self.check_input('activityId')
		program_list = Programe.selectByActivity(Activity.selectById(self.input['activityId']))
		if not program_list:
			raise InputError('no such activity')
		show_list = []
		for program in program_list:
			show_list.append(
				{
					'name': program.name,
					'sequence': program.sequence,
					'actors': program.actors
				}
			)
		return {'view': 40, 'list': show_list}
예제 #4
0
 def get(self):
     nid = self.request.GET.get('nid')
     programe = Programe.selectById(nid)
     num = str(int(programe.sequence) + 1)
     programe2 = Programe.objects.filter(activity=Activity.selectById(
         self.request.COOKIES['activityId']),
                                         sequence=num)
     if len(programe2) == 0:
         return {'view': 21}
     programe3 = programe2[0]
     if programe3:
         programe.updatePrograme(programe.id, programe.name,
                                 programe.description, programe.actors,
                                 programe3.sequence)
         programe.updatePrograme(programe3.id, programe3.name,
                                 programe3.description, programe3.actors,
                                 programe.sequence)
     return {'view': 21}
예제 #5
0
 def get(self):
     if not self.request.user.is_authenticated():
         raise ValidateError("Please login!")
     #self.check_input('programId')
     nid = self.request.GET.get('nid')
     programe = Programe.selectById(nid)
     if programe:
         data = {
             'name': programe.name,
             'description': programe.description,
             'sequence': programe.sequence,
             'actors': programe.actors
         }
         return {
             'view': 23,
             'name': data['name'],
             'description': data['description'],
             'actors': data['actors']
         }
     else:
         raise InputError('no such programe')
예제 #6
0
    def post(self):
        if not self.request.user.is_authenticated():
            raise ValidateError("Please login!")
        #self.check_input('programId')
        if 'edit' in self.request.POST:
            nid = self.request.GET.get('nid')
            programe = Programe.selectById(nid)
            old_programe = programe
            if programe:
                programe.updatePrograme(programe.id, self.input['name'],
                                        self.input['description'],
                                        self.input['actors'],
                                        programe.sequence)
            #else:
            #raise ValidateError('no such program')
            #programe.save()
            #if old_programe == programe:
            #return {'view': 21}
            #else:
            #return {'view': 21}
            return {'view': 21}

        if 'return' in self.request.POST:
            return {'view': 21}
예제 #7
0
 def post(self):
     if not self.request.user.is_authenticated():
         raise ValidateError("Please login!")
     self.check_input('programId')
     Programe.deletePrograme(self.input['programId'])