<s> from django . conf import settings <EOL> from django . contrib . auth import get_user_model <EOL> from django . contrib . auth . models import Group <EOL> from django . http import Http404 <EOL> from django . shortcuts import get_object_or_404 <EOL> from stackdio . ui . views import PageView , ModelPermissionsView , ObjectPermissionsView <EOL> from stackdio . ui . utils import get_object_list <EOL> class FailOnLDAPMixin ( object ) : <EOL> def render_to_response ( self , context , ** response_kwargs ) : <EOL> if settings . LDAP_ENABLED : <EOL> self . template_name = '<STR_LIT>' <EOL> response_kwargs [ '<STR_LIT:status>' ] = <NUM_LIT> <EOL> return super ( FailOnLDAPMixin , self ) . render_to_response ( context , ** response_kwargs ) <EOL> class UserProfileView ( PageView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( UserProfileView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT>' ] = settings . LDAP_ENABLED <EOL> return context <EOL> class UserPasswordChangeView ( FailOnLDAPMixin , PageView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> class UserCreateView ( FailOnLDAPMixin , PageView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> def get ( self , request , * args , ** kwargs ) : <EOL> if not request . user . has_perm ( '<STR_LIT>' ) : <EOL> raise Http404 ( ) <EOL> return super ( UserCreateView , self ) . get ( request , * args , ** kwargs ) <EOL> class UserListView ( PageView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( UserListView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' ) <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' ) <EOL> context [ '<STR_LIT>' ] = settings . LDAP_ENABLED <EOL> return context <EOL> class UserModelPermissionsView ( ModelPermissionsView ) : <EOL> viewmodel = '<STR_LIT>' <EOL> model = get_user_model ( ) <EOL> class GroupCreateView ( PageView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> def get ( self , request , * args , ** kwargs ) : <EOL> if not request . user . has_perm ( '<STR_LIT>' ) : <EOL> raise Http404 ( ) <EOL> return super ( GroupCreateView , self ) . get ( request , * args , ** kwargs ) <EOL> class GroupListView ( PageView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( GroupListView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' ) <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' ) <EOL> context [ '<STR_LIT>' ] = get_object_list ( self . request . user , Group , '<STR_LIT:name>' ) <EOL> return context <EOL> class GroupModelPermissionsView ( ModelPermissionsView ) : <EOL> viewmodel = '<STR_LIT>' <EOL> model = Group <EOL> class GroupDetailView ( PageView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> page_id = '<STR_LIT>' <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( GroupDetailView , self ) . get_context_data ( ** kwargs ) <EOL> name = kwargs [ '<STR_LIT:name>' ] <EOL> group = get_object_or_404 ( Group . objects . all ( ) , name = name ) <EOL> if not self . request . user . has_perm ( '<STR_LIT>' , group ) : <EOL> raise Http404 ( ) <EOL> context [ '<STR_LIT>' ] = group <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' , group ) <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' , group ) <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' , group ) <EOL> context [ '<STR_LIT>' ] = self . page_id <EOL> return context <EOL> class GroupObjectPermissionsView ( ObjectPermissionsView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> page_id = '<STR_LIT>' <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( GroupObjectPermissionsView , self ) . get_context_data ( ** kwargs ) <EOL> name = kwargs [ '<STR_LIT:name>' ] <EOL> group = get_object_or_404 ( Group . objects . all ( ) , name = name ) <EOL> if not self . request . user . has_perm ( '<STR_LIT>' , group ) : <EOL> raise Http404 ( ) <EOL> context [ '<STR_LIT>' ] = group <EOL> context [ '<STR_LIT>' ] = name <EOL> context [ '<STR_LIT>' ] = self . request . user . has_perm ( '<STR_LIT>' , group ) <EOL> context [ '<STR_LIT>' ] = self . page_id <EOL> return context <EOL> def get_object ( self ) : <EOL> return get_object_or_404 ( Group . objects . all ( ) , name = self . kwargs [ '<STR_LIT:name>' ] ) <EOL> class GroupMembersView ( GroupDetailView ) : <EOL> template_name = '<STR_LIT>' <EOL> viewmodel = '<STR_LIT>' <EOL> page_id = '<STR_LIT>' </s>
