Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

# This program is distributed in the hope that it will be useful, but WITHOUT 

# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 

# FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for 

# more details. 

# 

# You should have received a copy of the GNU General Public License version 3 

# along with this program; if not, write to the Free Software Foundation, Inc., 51 

# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 

# 

# (c) 2015-2016 Valentin Samir 

"""module for the admin interface of the app""" 

from .default_settings import settings 

 

from django.contrib import admin 

from .models import ServiceTicket, ProxyTicket, ProxyGrantingTicket, User, ServicePattern 

from .models import Username, ReplaceAttributName, ReplaceAttributValue, FilterAttributValue 

from .models import FederatedIendityProvider, FederatedUser, UserAttributes 

from .forms import TicketForm 

 

 

class BaseInlines(admin.TabularInline): 

""" 

Bases: :class:`django.contrib.admin.TabularInline` 

 

Base class for inlines in the admin interface. 

""" 

#: This controls the number of extra forms the formset will display in addition to 

#: the initial forms. 

extra = 0 

 

 

class UserAdminInlines(BaseInlines): 

""" 

Bases: :class:`BaseInlines` 

 

Base class for inlines in :class:`UserAdmin` interface 

""" 

#: The form :class:`TicketForm<cas_server.forms.TicketForm>` used to display tickets. 

form = TicketForm 

#: Fields to display on a object that are read only (not editable). 

readonly_fields = ( 

'validate', 'service', 'service_pattern', 

'creation', 'renew', 'single_log_out', 'value' 

) 

#: Fields to display on a object. 

fields = ( 

'validate', 'service', 'service_pattern', 

'creation', 'renew', 'single_log_out' 

) 

 

 

class ServiceTicketInline(UserAdminInlines): 

""" 

Bases: :class:`UserAdminInlines` 

 

:class:`ServiceTicket<cas_server.models.ServiceTicket>` in admin interface 

""" 

#: The model which the inline is using. 

model = ServiceTicket 

 

 

class ProxyTicketInline(UserAdminInlines): 

""" 

Bases: :class:`UserAdminInlines` 

 

:class:`ProxyTicket<cas_server.models.ProxyTicket>` in admin interface 

""" 

#: The model which the inline is using. 

model = ProxyTicket 

 

 

class ProxyGrantingInline(UserAdminInlines): 

""" 

Bases: :class:`UserAdminInlines` 

 

:class:`ProxyGrantingTicket<cas_server.models.ProxyGrantingTicket>` in admin interface 

""" 

#: The model which the inline is using. 

model = ProxyGrantingTicket 

 

 

class UserAdmin(admin.ModelAdmin): 

""" 

Bases: :class:`django.contrib.admin.ModelAdmin` 

 

:class:`User<cas_server.models.User>` in admin interface 

""" 

#: See :class:`ServiceTicketInline`, :class:`ProxyTicketInline`, :class:`ProxyGrantingInline` 

#: objects below the :class:`UserAdmin` fields. 

inlines = (ServiceTicketInline, ProxyTicketInline, ProxyGrantingInline) 

#: Fields to display on a object that are read only (not editable). 

readonly_fields = ('username', 'date', "session_key") 

#: Fields to display on a object. 

fields = ('username', 'date', "session_key") 

#: Fields to display on the list of class:`UserAdmin` objects. 

list_display = ('username', 'date', "session_key") 

 

 

class UsernamesInline(BaseInlines): 

""" 

Bases: :class:`BaseInlines` 

 

:class:`Username<cas_server.models.Username>` in admin interface 

""" 

#: The model which the inline is using. 

model = Username 

 

 

class ReplaceAttributNameInline(BaseInlines): 

""" 

Bases: :class:`BaseInlines` 

 

:class:`ReplaceAttributName<cas_server.models.ReplaceAttributName>` in admin interface 

""" 

#: The model which the inline is using. 

model = ReplaceAttributName 

 

 

class ReplaceAttributValueInline(BaseInlines): 

""" 

Bases: :class:`BaseInlines` 

 

:class:`ReplaceAttributValue<cas_server.models.ReplaceAttributValue>` in admin interface 

""" 

#: The model which the inline is using. 

model = ReplaceAttributValue 

 

 

class FilterAttributValueInline(BaseInlines): 

""" 

Bases: :class:`BaseInlines` 

 

:class:`FilterAttributValue<cas_server.models.FilterAttributValue>` in admin interface 

""" 

#: The model which the inline is using. 

model = FilterAttributValue 

 

 

class ServicePatternAdmin(admin.ModelAdmin): 

""" 

Bases: :class:`django.contrib.admin.ModelAdmin` 

 

:class:`ServicePattern<cas_server.models.ServicePattern>` in admin interface 

""" 

#: See :class:`UsernamesInline`, :class:`ReplaceAttributNameInline`, 

#: :class:`ReplaceAttributValueInline`, :class:`FilterAttributValueInline` objects below 

#: the :class:`ServicePatternAdmin` fields. 

inlines = ( 

UsernamesInline, 

ReplaceAttributNameInline, 

ReplaceAttributValueInline, 

FilterAttributValueInline 

) 

#: Fields to display on the list of class:`ServicePatternAdmin` objects. 

list_display = ('pos', 'name', 'pattern', 'proxy', 

'single_log_out', 'proxy_callback', 'restrict_users') 

 

 

class FederatedIendityProviderAdmin(admin.ModelAdmin): 

""" 

Bases: :class:`django.contrib.admin.ModelAdmin` 

 

:class:`FederatedIendityProvider<cas_server.models.FederatedIendityProvider>` in admin 

interface 

""" 

#: Fields to display on a object. 

fields = ('pos', 'suffix', 'server_url', 'cas_protocol_version', 'verbose_name', 'display') 

#: Fields to display on the list of class:`FederatedIendityProviderAdmin` objects. 

list_display = ('verbose_name', 'suffix', 'display') 

 

 

class FederatedUserAdmin(admin.ModelAdmin): 

""" 

Bases: :class:`django.contrib.admin.ModelAdmin` 

 

:class:`FederatedUser<cas_server.models.FederatedUser>` in admin 

interface 

""" 

#: Fields to display on a object. 

fields = ('username', 'provider', 'last_update') 

#: Fields to display on the list of class:`FederatedUserAdmin` objects. 

list_display = ('username', 'provider', 'last_update') 

 

 

class UserAttributesAdmin(admin.ModelAdmin): 

""" 

Bases: :class:`django.contrib.admin.ModelAdmin` 

 

:class:`UserAttributes<cas_server.models.UserAttributes>` in admin 

interface 

""" 

#: Fields to display on a object. 

fields = ('username', '_attributs') 

 

 

admin.site.register(ServicePattern, ServicePatternAdmin) 

admin.site.register(FederatedIendityProvider, FederatedIendityProviderAdmin) 

if settings.DEBUG: # pragma: no branch (we always test with DEBUG True) 

admin.site.register(User, UserAdmin) 

admin.site.register(FederatedUser, FederatedUserAdmin) 

admin.site.register(UserAttributes, UserAttributesAdmin)