def system_state(request): if not request.user or not request.user.is_superuser: raise Http404 components_values = [y.render(request) for y in system_checks] template_values = {'components': components_values} set_websocket_topics(request) return TemplateResponse(request, template='easydjango/bootstrap3/system_state.html', context=template_values)
def get(self, request, *args, **kwargs): logger.debug('debug log message') logger.info('info log message') logger.warn('warn log message') logger.error('error log message') messages.error(request, 'message (error)') set_websocket_topics(request) form = TestForm() template_values = {'form': form, 'title': 'Hello, world!'} return self.render_to_response(template_values)
def chat(request): name = None if request.method == 'POST': form = ChatLoginForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] form = None set_websocket_topics(request, WINDOW, 'chat-%s' % name) else: form = ChatLoginForm() set_websocket_topics(request, WINDOW) template_values = {'form': form, 'name': name} return TemplateResponse(request, 'easydemo/chat.html', template_values)
def get_or_post(self, request, form): pattern = form.cleaned_data['q'] if form.is_valid() else None search_query = self.get_query(pattern=pattern) page = request.GET.get('page') paginator = Paginator(search_query, 25) try: paginated_results = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. paginated_results = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. paginated_results = paginator.page(paginator.num_pages) context = {'form': form, 'paginated_url': '%s?%s' % (reverse('ed:site_search'), urlencode({'q': pattern})), 'paginated_results': paginated_results, 'formatted_results': self.formatted_results(paginated_results), 'formatted_header': self.formatted_header(), } extra_context = self.get_template_values(request) context.update(extra_context) set_websocket_topics(request) return self.render_to_response(context)
def post(self, request): set_websocket_topics(request) form = TestForm(request.POST) form.is_valid() template_values = {'form': form, 'title': 'Hello, world!'} return self.render_to_response(template_values)