<s> from __future__ import absolute_import <EOL> import codecs <EOL> from django . contrib . auth . models import User <EOL> from django . http import HttpResponse <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . views . generic import ( View , UpdateView , FormView , TemplateView , <EOL> ListView , DetailView , CreateView ) <EOL> from braces import views <EOL> from . models import Article , CanonicalArticle <EOL> from . forms import ArticleForm , FormWithUserKwarg <EOL> from . helpers import SetJSONEncoder <EOL> class OkView ( View ) : <EOL> """<STR_LIT>""" <EOL> def get ( self , request ) : <EOL> return HttpResponse ( "<STR_LIT:OK>" ) <EOL> def post ( self , request ) : <EOL> return self . get ( request ) <EOL> def put ( self , request ) : <EOL> return self . get ( request ) <EOL> def delete ( self , request ) : <EOL> return self . get ( request ) <EOL> class LoginRequiredView ( views . LoginRequiredMixin , OkView ) : <EOL> """<STR_LIT>""" <EOL> class AnonymousRequiredView ( views . AnonymousRequiredMixin , OkView ) : <EOL> """<STR_LIT>""" <EOL> authenticated_redirect_url = '<STR_LIT>' <EOL> class AuthenticatedView ( views . LoginRequiredMixin , OkView ) : <EOL> """<STR_LIT>""" <EOL> class AjaxResponseView ( views . AjaxResponseMixin , OkView ) : <EOL> """<STR_LIT>""" <EOL> def get_ajax ( self , request ) : <EOL> return HttpResponse ( "<STR_LIT>" ) <EOL> def post_ajax ( self , request ) : <EOL> return self . get_ajax ( request ) <EOL> def put_ajax ( self , request ) : <EOL> return self . get_ajax ( request ) <EOL> def delete_ajax ( self , request ) : <EOL> return self . get_ajax ( request ) <EOL> class SimpleJsonView ( views . JSONResponseMixin , View ) : <EOL> """<STR_LIT>""" <EOL> def get ( self , request ) : <EOL> object = { '<STR_LIT:username>' : request . user . username } <EOL> return self . render_json_response ( object ) <EOL> class CustomJsonEncoderView ( views . JSONResponseMixin , View ) : <EOL> """<STR_LIT>""" <EOL> json_encoder_class = SetJSONEncoder <EOL> def get ( self , request ) : <EOL> object = { '<STR_LIT>' : set ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) } <EOL> return self . render_json_response ( object ) <EOL> class SimpleJsonBadRequestView ( views . JSONResponseMixin , View ) : <EOL> """<STR_LIT>""" <EOL> def get ( self , request ) : <EOL> object = { '<STR_LIT:username>' : request . user . username } <EOL> return self . render_json_response ( object , status = <NUM_LIT> ) <EOL> class ArticleListJsonView ( views . JSONResponseMixin , View ) : <EOL> """<STR_LIT>""" <EOL> def get ( self , request ) : <EOL> queryset = Article . objects . all ( ) <EOL> return self . render_json_object_response ( <EOL> queryset , fields = ( '<STR_LIT:title>' , ) ) <EOL> class JsonRequestResponseView ( views . JsonRequestResponseMixin , View ) : <EOL> """<STR_LIT>""" <EOL> def post ( self , request ) : <EOL> return self . render_json_response ( self . request_json ) <EOL> class JsonBadRequestView ( views . JsonRequestResponseMixin , View ) : <EOL> """<STR_LIT>""" <EOL> require_json = True <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> return self . render_json_response ( self . request_json ) <EOL> class JsonCustomBadRequestView ( views . JsonRequestResponseMixin , View ) : <EOL> """<STR_LIT>""" <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> if not self . request_json : <EOL> return self . render_bad_request_response ( <EOL> { '<STR_LIT:error>' : '<STR_LIT>' } ) <EOL> return self . render_json_response ( self . request_json ) <EOL> class CreateArticleView ( CreateView ) : <EOL> """<STR_LIT>""" <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:title>' , '<STR_LIT:body>' , '<STR_LIT>' ] <EOL> model = Article <EOL> template_name = '<STR_LIT>' <EOL> class EditArticleView ( UpdateView ) : <EOL> """<STR_LIT>""" <EOL> model = Article <EOL> template_name = '<STR_LIT>' <EOL> class CreateArticleAndRedirectToListView ( views . SuccessURLRedirectListMixin , <EOL> CreateArticleView ) : <EOL> """<STR_LIT>""" <EOL> success_list_url = '<STR_LIT>' <EOL> class CreateArticleAndRedirectToListViewBad ( views . SuccessURLRedirectListMixin , <EOL> CreateArticleView ) : <EOL> """<STR_LIT>""" <EOL> success_list_url = None <EOL> class ArticleListView ( views . SelectRelatedMixin , ListView ) : <EOL> """<STR_LIT>""" <EOL> model = Article <EOL> template_name = '<STR_LIT>' <EOL> select_related = ( '<STR_LIT>' , ) <EOL> class ArticleListViewWithCustomQueryset ( views . SelectRelatedMixin , ListView ) : <EOL> """<STR_LIT>""" <EOL> queryset = Article . objects . select_related ( '<STR_LIT>' ) . prefetch_related ( <EOL> '<STR_LIT>' ) <EOL> template_name = '<STR_LIT>' <EOL> select_related = ( ) <EOL> class FormWithUserKwargView ( views . UserFormKwargsMixin , FormView ) : <EOL> """<STR_LIT>""" <EOL> form_class = FormWithUserKwarg <EOL> template_name = '<STR_LIT>' <EOL> def form_valid ( self , form ) : <EOL> return HttpResponse ( "<STR_LIT>" % form . user . username ) <EOL> class HeadlineView ( views . SetHeadlineMixin , TemplateView ) : <EOL> """<STR_LIT>""" <EOL> template_name = '<STR_LIT>' <EOL> headline = "<STR_LIT>" <EOL> class LazyHeadlineView ( views . SetHeadlineMixin , TemplateView ) : <EOL> """<STR_LIT>""" <EOL> template_name = '<STR_LIT>' <EOL> headline = _ ( "<STR_LIT>" ) <EOL> class ContextView ( views . StaticContextMixin , TemplateView ) : <EOL> """<STR_LIT>""" <EOL> template_name = '<STR_LIT>' <EOL> static_context = { '<STR_LIT:test>' : True } <EOL> class DynamicHeadlineView ( views . SetHeadlineMixin , TemplateView ) : <EOL> """<STR_LIT>""" <EOL> template_name = '<STR_LIT>' <EOL> def get_headline ( self ) : <EOL> return self . kwargs [ '<STR_LIT:s>' ] <EOL> class PermissionRequiredView ( views . PermissionRequiredMixin , OkView ) : <EOL> """<STR_LIT>""" <EOL> permission_required = '<STR_LIT>' <EOL> class MultiplePermissionsRequiredView ( views . MultiplePermissionsRequiredMixin , <EOL> OkView ) : <EOL> permissions = { <EOL> '<STR_LIT:all>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } <EOL> class SuperuserRequiredView ( views . SuperuserRequiredMixin , OkView ) : <EOL> pass <EOL> class StaffuserRequiredView ( views . StaffuserRequiredMixin , OkView ) : <EOL> pass <EOL> class CsrfExemptView ( views . CsrfExemptMixin , OkView ) : <EOL> pass <EOL> class AuthorDetailView ( views . PrefetchRelatedMixin , ListView ) : <EOL> model = User <EOL> prefetch_related = [ '<STR_LIT>' ] <EOL> template_name = '<STR_LIT>' <EOL> class OrderableListView ( views . OrderableListMixin , ListView ) : <EOL> model = Article <EOL> orderable_columns = ( '<STR_LIT:id>' , '<STR_LIT:title>' , ) <EOL> orderable_columns_default = '<STR_LIT:id>' <EOL> class CanonicalSlugDetailView ( views . CanonicalSlugDetailMixin , DetailView ) : <EOL> model = Article <EOL> template_name = '<STR_LIT>' <EOL> class OverriddenCanonicalSlugDetailView ( views . CanonicalSlugDetailMixin , <EOL> DetailView ) : <EOL> model = Article <EOL> template_name = '<STR_LIT>' <EOL> def get_canonical_slug ( self ) : <EOL> return codecs . encode ( self . get_object ( ) . slug , '<STR_LIT>' ) <EOL> class CanonicalSlugDetailCustomUrlKwargsView ( views . CanonicalSlugDetailMixin , <EOL> DetailView ) : <EOL> model = Article <EOL> template_name = '<STR_LIT>' <EOL> pk_url_kwarg = '<STR_LIT>' <EOL> slug_url_kwarg = '<STR_LIT>' <EOL> class ModelCanonicalSlugDetailView ( views . CanonicalSlugDetailMixin , <EOL> DetailView ) : <EOL> model = CanonicalArticle <EOL> template_name = '<STR_LIT>' <EOL> class FormMessagesView ( views . FormMessagesMixin , CreateView ) : <EOL> form_class = ArticleForm <EOL> form_invalid_message = _ ( '<STR_LIT>' ) <EOL> form_valid_message = _ ( '<STR_LIT>' ) <EOL> model = Article <EOL> success_url = '<STR_LIT>' <EOL> template_name = '<STR_LIT>' <EOL> class GroupRequiredView ( views . GroupRequiredMixin , OkView ) : <EOL> group_required = '<STR_LIT>' <EOL> class UserPassesTestView ( views . UserPassesTestMixin , OkView ) : <EOL> def test_func ( self , user ) : <EOL> return user . is_staff and not user . is_superuser and user . email . endswith ( '<STR_LIT>' ) <EOL> class UserPassesTestNotImplementedView ( views . UserPassesTestMixin , OkView ) : <EOL> pass <EOL> class AllVerbsView ( views . AllVerbsMixin , View ) : <EOL> def all ( self , request , * args , ** kwargs ) : <EOL> return HttpResponse ( '<STR_LIT>' ) <EOL> class SSLRequiredView ( views . SSLRequiredMixin , OkView ) : <EOL> pass <EOL> class RecentLoginRequiredView ( views . RecentLoginRequiredMixin , OkView ) : <EOL> """<STR_LIT>""" </s>
