def post(self, request, select): #print("RandomList POST") mycache = cu.MyCache(request) if 'save-query' in request.POST: return redirect(reverse('cached_list')) rlist = [] bound_form = self.form_class(request.POST) if bound_form.is_valid(): count = bound_form.cleaned_data['count'] if select == 'saturday-morning': rlist = rq.saturday_select(count) elif select == 'sitcom': rlist = rq.sitcom_select(count) elif select == 'silly': rlist = rq.silly_select(count) elif select == 'scifi': rlist = rq.scifi_select(count) elif select == 'drama': rlist = rq.drama_select(count) elif select == 'scary': rlist = rq.scary_select(count) # cache the list cu.cache_list_bykind(rlist, choices.MOVIE, 'special_channel', mycache) # display the list as files with the form title = ('Build a channel %s' % (select)) context = {'form': bound_form, 'rlist': rlist, 'title': title} return render(request, self.template_name, context)
def post(self, request): #print("RandomList POST") mycache = cu.MyCache(request) if 'save-query' in request.POST: return redirect(reverse('cached_list')) rlist = [] bound_form = self.form_class(request.POST) if bound_form.is_valid(): #print(' valid form ') count = bound_form.cleaned_data['count'] kind = bound_form.cleaned_data['kind'] tag = bound_form.cleaned_data['tag'] title = bound_form.cleaned_data['atitle'] #print( kind ) rlist = rq.random_select(count, title, tag, kind) cu.cache_list_bykind(rlist, kind, 'random_list', mycache) # display the list as files with the form context = { 'form': bound_form, 'rlist': rlist, 'title': 'Build a Random Channel' } return render(request, self.template_name, context)
def post(self, request): mycache = cu.MyCache(request) rlist = [] bound_form = self.form_class(request.POST) if bound_form.is_valid(): rlist = bound_form.cleaned_data['choices'] cu.cache_list_bykind(rlist, choices.SONG, 'special_channel', mycache) return redirect(reverse('cached_list')) # display the list as files with the form context = { 'form': bound_form, 'rlist': rlist, 'title': 'Build a Channel' } return render(request, self.template_name, context)
def post(self, request): #print("RadioChannel POST") me = rq.get_me(True, request) mycache = cu.MyCache(request) if 'save-query' in request.POST: return redirect(reverse('cached_list')) rlist = [] bound_form = self.form_class(request.POST) if me is None: # hide field from anonymous user bound_form.fields['kind'].widget = HiddenInput() if bound_form.is_valid(): count = bound_form.cleaned_data['count'] kind = bound_form.cleaned_data['kind'] xmas = bound_form.cleaned_data['xmas'] recent = bound_form.cleaned_data['recent'] cl = bound_form.cleaned_data['classic'] justme = False if kind == choices.ME: justme = True if recent: rlist = rq.radio_recent(justme, me, cl, xmas, count) else: target = rq.radio_all(justme, me, cl, xmas) rlist = target[:count] cu.cache_list_bykind(rlist, choices.SONG, 'special_channel', mycache) if recent: # recent case simply move to cached list return redirect(reverse('cached_list')) # display the list as files with the form context = { 'form': bound_form, 'rlist': rlist, 'title': 'Build a Channel' } return render(request, self.template_name, context)
def post(self, request): #print("RecentList POST") mycache = cu.MyCache(request) rlist = [] bound_form = self.form_class(request.POST) if bound_form.is_valid(): count = bound_form.cleaned_data['count'] kind = bound_form.cleaned_data['kind'] rlist = rq.recent_bykind(kind, count) cu.cache_list_bykind(rlist, kind, 'random_list', mycache) return redirect(reverse('cached_list')) # display the list as files with the form context = { 'form': bound_form, 'rlist': rlist, 'title': 'Build a Recent Channel' } return render(request, self.template_name, context)
def post(self, request, akind): mycache = cu.MyCache(request) if 'save-query' in request.POST: return redirect(reverse('cached_list')) kind = akind #self.getKind(akind) rlist = [] bound_form = self.form_class(request.POST) if bound_form.is_valid(): count = bound_form.cleaned_data['count'] title = bound_form.cleaned_data['atitle'] tag = bound_form.cleaned_data['atag'] random = bound_form.cleaned_data['random'] rlist = rq.random_select(count, title, tag, kind, random) cu.cache_list_bykind(rlist, kind, 'random_list', mycache) title = ('Build a channel %s' % (akind)) # display the list as files with the form context = {'form': bound_form, 'rlist': rlist, 'title': title} return render(request, self.template_name, context)