def get_response(self, request, req_context, options, content_object): p = content_object.flash.url_full i = p.rfind("/") + 1 base = p[:i] req_context.update({'url_base': base}) return views.object_detail(request, req_context, content_object, **self.params)
def get_response(self, request, req_context, options, content_object): avatar = None if content_object.user: try: profile = content_object.user.get_profile() avatar = profile.avatar except ObjectDoesNotExist: pass req_context.update({'avatar': avatar}) return views.object_detail(request, req_context, content_object)
def get_response(self, request, req_context, options, content_object): if not options['limit_to_n_items']: options['limit_to_n_items'] = content_object.number_of_entries if not options['titles_only']: options['titles_only'] = content_object.titles_only now = datetime.now() d, last_access = self._feed_cache.get(content_object.url, (None, None)) if d is None or total_seconds(now - last_access) > cyc_settings.CYCLOPE_FEED_CACHE_TIME: d = feedparser.parse(content_object.url) self._feed_cache[content_object.url] = (d, now) context = {'entries': d.entries[:options['limit_to_n_items']]} return views.object_detail(request, req_context, content_object, extra_context=context)
def get_response(self, request, req_context, options, content_object): if not request.user.is_authenticated(): form_class = CreateTopicCaptchaForm else: form_class = CreateTopicForm category = content_object req_context.update({'forum': category.name}) topic_ctype = ContentType.objects.get_for_model(Topic) if topic_ctype not in category.collection.content_types.all(): not_allowed = True form = None else: not_allowed = False if request.method == 'POST': form = form_class(data=request.POST) if form.is_valid(): # partial save topic = form.save(commit=False) if request.user.is_authenticated(): topic.user = request.user topic.allow_comments = 'YES' topic.save() # category added topic.categories.get_or_create(category=category, defaults={'category': category, 'content_type_id': topic_ctype.id, 'object_id': topic.id}) topic.save() return redirect(topic) else: form = form_class() req_context.update({'form': form, 'not_allowed': not_allowed, 'action_url': reverse('category-create_topic', args=[category.slug]), }) return views.object_detail(request, req_context, content_object, view_name = self.name)
def get_response(self, request, req_context, options, content_object): return views.object_detail(request, req_context, content_object)