add base url to services

This commit is contained in:
Frédéric Péters 2014-03-25 13:51:38 +01:00
parent 72534e10f2
commit 4e1f40c9c1
4 changed files with 18 additions and 4 deletions

View File

@ -3,8 +3,9 @@ from django.utils.translation import ugettext_lazy as _
class IdentityProvider(models.Model):
title = models.CharField(max_length=50)
title = models.CharField(_('Title'), max_length=50)
slug = models.SlugField()
base_url = models.CharField(_('Base URL'), max_length=200)
class Meta:
verbose_name = _('Identity Provider')
@ -15,8 +16,9 @@ class IdentityProvider(models.Model):
class WebForms(models.Model):
title = models.CharField(max_length=50)
title = models.CharField(_('Title'), max_length=50)
slug = models.SlugField()
base_url = models.CharField(_('Base URL'), max_length=200)
class Meta:
verbose_name = _('Web Forms')

View File

@ -9,8 +9,8 @@
<form class="small">
<p>
<label for="domain-template">{% trans 'Domain Template:' %}</label>
<input type="text" id="domain-template" size="20" value="{domain}.example.net"/ >
<label for="url-template">{% trans 'URL Template:' %}</label>
<input type="text" id="url-template" size="30" value="{{ url_template }}"/ >
</p>
<button disabled="disabled">{% trans 'Save' %}</button>
</form>

View File

@ -1,3 +1,6 @@
import string
from django.conf import settings
from django.core.urlresolvers import reverse_lazy
from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView
@ -17,6 +20,7 @@ class HomeView(TemplateView):
def get_context_data(self, **kwargs):
context = super(HomeView, self).get_context_data(**kwargs)
context['url_template'] = settings.SERVICE_URL_TEMPLATE
context['available_services'] = [
AvailableService(x) for x in AVAILABLE_SERVICES]
installed_services = []
@ -34,6 +38,12 @@ class ServiceCreateView(CreateView):
context['model_name'] = self.model._meta.verbose_name
return context
def get_initial(self):
initial = super(ServiceCreateView, self).get_initial()
initial['base_url'] = string.Template(settings.SERVICE_URL_TEMPLATE
).substitute({'app': self.model.Extra.service_id})
return initial
def get_template_names(self):
return 'environment/service_form.html'

View File

@ -95,3 +95,5 @@ STATICFILES_DIRS = (
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'hobo', 'locale'),
)
SERVICE_URL_TEMPLATE = 'https://${app}.example.net'