2015-05-19 13:27:04 +00:00
|
|
|
from django.conf.urls import url
|
2014-05-08 16:59:35 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
|
|
from orchestra.admin import ExtendedModelAdmin
|
2015-07-21 10:44:32 +00:00
|
|
|
from orchestra.contrib.accounts.actions import list_accounts
|
2015-04-05 10:46:24 +00:00
|
|
|
from orchestra.contrib.accounts.admin import AccountAdminMixin
|
2015-08-05 22:58:35 +00:00
|
|
|
from orchestra.forms import UserCreationForm, NonStoredUserChangeForm
|
2014-05-08 16:59:35 +00:00
|
|
|
|
|
|
|
from .models import VPS
|
|
|
|
|
|
|
|
|
|
|
|
class VPSAdmin(AccountAdminMixin, ExtendedModelAdmin):
|
|
|
|
list_display = ('hostname', 'type', 'template', 'account_link')
|
|
|
|
list_filter = ('type', 'template')
|
2015-08-05 22:58:35 +00:00
|
|
|
form = NonStoredUserChangeForm
|
|
|
|
add_form = UserCreationForm
|
2014-05-08 16:59:35 +00:00
|
|
|
readonly_fields = ('account_link',)
|
2015-08-05 22:58:35 +00:00
|
|
|
change_readonly_fields = ('account', 'hostname', 'type', 'template')
|
2014-05-08 16:59:35 +00:00
|
|
|
fieldsets = (
|
|
|
|
(None, {
|
|
|
|
'classes': ('wide',),
|
|
|
|
'fields': ('account_link', 'hostname', 'type', 'template')
|
|
|
|
}),
|
|
|
|
(_("Login"), {
|
|
|
|
'classes': ('wide',),
|
|
|
|
'fields': ('password',)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
add_fieldsets = (
|
|
|
|
(None, {
|
|
|
|
'classes': ('wide',),
|
|
|
|
'fields': ('account', 'hostname', 'type', 'template')
|
|
|
|
}),
|
|
|
|
(_("Login"), {
|
|
|
|
'classes': ('wide',),
|
|
|
|
'fields': ('password1', 'password2',)
|
|
|
|
}),
|
|
|
|
)
|
2015-07-21 10:44:32 +00:00
|
|
|
actions = (list_accounts,)
|
2014-05-08 16:59:35 +00:00
|
|
|
|
|
|
|
def get_urls(self):
|
|
|
|
useradmin = UserAdmin(VPS, self.admin_site)
|
2015-05-19 13:27:04 +00:00
|
|
|
return [
|
|
|
|
url(r'^(\d+)/password/$',
|
|
|
|
self.admin_site.admin_view(useradmin.user_change_password))
|
|
|
|
] + super(VPSAdmin, self).get_urls()
|
2014-05-08 16:59:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(VPS, VPSAdmin)
|