do not use generic names for models
This commit is contained in:
parent
2ec376d44a
commit
904c83be25
|
@ -1,27 +1,27 @@
|
|||
from django import forms
|
||||
from django.template.defaultfilters import slugify
|
||||
|
||||
from .models import IdentityProvider, WebForms
|
||||
from .models import Authentic, Wcs
|
||||
|
||||
class IdentityProviderForm(forms.ModelForm):
|
||||
class AuthenticForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = IdentityProvider
|
||||
model = Authentic
|
||||
exclude = ('slug', 'last_operational_check_timestamp',
|
||||
'last_operational_success_timestamp')
|
||||
|
||||
def save(self, commit=True):
|
||||
if not self.instance.slug:
|
||||
self.instance.slug = slugify(self.instance.title)
|
||||
return super(IdentityProviderForm, self).save(commit=commit)
|
||||
return super(AuthenticForm, self).save(commit=commit)
|
||||
|
||||
|
||||
class WebFormsForm(forms.ModelForm):
|
||||
class WcsForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = WebForms
|
||||
model = Wcs
|
||||
exclude = ('slug', 'last_operational_check_timestamp',
|
||||
'last_operational_success_timestamp')
|
||||
|
||||
def save(self, commit=True):
|
||||
if not self.instance.slug:
|
||||
self.instance.slug = slugify(self.instance.title)
|
||||
return super(WebFormsForm, self).save(commit=commit)
|
||||
return super(WcsForm, self).save(commit=commit)
|
||||
|
|
|
@ -47,10 +47,10 @@ class ServiceBase(models.Model):
|
|||
return as_dict
|
||||
|
||||
|
||||
class IdentityProvider(ServiceBase):
|
||||
class Authentic(ServiceBase):
|
||||
class Meta:
|
||||
verbose_name = _('Identity Provider')
|
||||
verbose_name_plural = _('Identity Providers')
|
||||
verbose_name = _('Authentic Identity Provider')
|
||||
verbose_name_plural = _('Authentic Identity Providers')
|
||||
|
||||
class Extra:
|
||||
service_id = 'idp'
|
||||
|
@ -62,10 +62,10 @@ class IdentityProvider(ServiceBase):
|
|||
]
|
||||
|
||||
|
||||
class WebForms(ServiceBase):
|
||||
class Wcs(ServiceBase):
|
||||
class Meta:
|
||||
verbose_name = _('Web Forms')
|
||||
verbose_name_plural = _('Web Forms')
|
||||
verbose_name = _('w.c.s. Web Forms')
|
||||
verbose_name_plural = _('.w.c.s. Web Forms')
|
||||
|
||||
class Extra:
|
||||
service_id = 'wcs'
|
||||
|
@ -76,4 +76,4 @@ class WebForms(ServiceBase):
|
|||
]
|
||||
|
||||
|
||||
AVAILABLE_SERVICES = [IdentityProvider, WebForms]
|
||||
AVAILABLE_SERVICES = [Authentic, Wcs]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
from django.template import Library
|
||||
|
||||
from ..models import IdentityProvider, WebForms, AVAILABLE_SERVICES
|
||||
from ..forms import IdentityProviderForm, WebFormsForm
|
||||
from ..models import Authentic, Wcs, AVAILABLE_SERVICES
|
||||
from ..forms import AuthenticForm, WcsForm
|
||||
|
||||
register = Library()
|
||||
|
||||
@register.filter(name='as_update_form')
|
||||
def as_update_form(object):
|
||||
if isinstance(object, IdentityProvider):
|
||||
return IdentityProviderForm(instance=object).as_p()
|
||||
if isinstance(object, WebForms):
|
||||
return WebFormsForm(instance=object).as_p()
|
||||
if isinstance(object, Authentic):
|
||||
return AuthenticForm(instance=object).as_p()
|
||||
if isinstance(object, Wcs):
|
||||
return WcsForm(instance=object).as_p()
|
||||
return None
|
||||
|
|
|
@ -6,8 +6,8 @@ urlpatterns = patterns('',
|
|||
url(r'^$', HomeView.as_view(), name='environment-home'),
|
||||
url(r'^check_operational/(?P<service>\w+)/(?P<slug>[\w-]+)$',
|
||||
operational_check_view, name='operational-check'),
|
||||
url(r'^new-idp$', IdentityProviderCreateView.as_view()),
|
||||
url(r'^new-wcs$', WebFormsCreateView.as_view()),
|
||||
url(r'^new-idp$', AuthenticCreateView.as_view()),
|
||||
url(r'^new-wcs$', WcsCreateView.as_view()),
|
||||
url(r'^installed_services.json$', installed_services_json_view),
|
||||
url(r'^operational_services.json$', operational_services_json_view),
|
||||
)
|
||||
|
|
|
@ -7,8 +7,8 @@ from django.http import HttpResponse
|
|||
from django.views.generic.base import TemplateView
|
||||
from django.views.generic.edit import CreateView
|
||||
|
||||
from .models import IdentityProvider, WebForms, AVAILABLE_SERVICES
|
||||
from .forms import IdentityProviderForm, WebFormsForm
|
||||
from .models import Authentic, Wcs, AVAILABLE_SERVICES
|
||||
from .forms import AuthenticForm, WcsForm
|
||||
from . import utils
|
||||
|
||||
|
||||
|
@ -48,21 +48,21 @@ class ServiceCreateView(CreateView):
|
|||
return 'environment/service_form.html'
|
||||
|
||||
|
||||
class IdentityProviderCreateView(ServiceCreateView):
|
||||
form_class = IdentityProviderForm
|
||||
model = IdentityProvider
|
||||
class AuthenticCreateView(ServiceCreateView):
|
||||
form_class = AuthenticForm
|
||||
model = Authentic
|
||||
|
||||
|
||||
class WebFormsCreateView(ServiceCreateView):
|
||||
form_class = WebFormsForm
|
||||
model = WebForms
|
||||
class WcsCreateView(ServiceCreateView):
|
||||
form_class = WcsForm
|
||||
model = Wcs
|
||||
|
||||
|
||||
def operational_check_view(request, service, slug, **kwargs):
|
||||
if service == 'wcs':
|
||||
object = WebForms.objects.get(slug=slug)
|
||||
object = Wcs.objects.get(slug=slug)
|
||||
elif service == 'idp':
|
||||
object = IdentityProvider.objects.get(slug=slug)
|
||||
object = Authentic.objects.get(slug=slug)
|
||||
object.check_operational()
|
||||
response = HttpResponse(content_type='application/json')
|
||||
json.dump({'operational': object.is_operational()}, response)
|
||||
|
|
Loading…
Reference in New Issue