aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/forms/admin.py57
-rw-r--r--servo/templates/admin/settings.html8
-rw-r--r--settings.py3
3 files changed, 54 insertions, 14 deletions
diff --git a/servo/forms/admin.py b/servo/forms/admin.py
index 42a0b0d..b0c7c54 100644
--- a/servo/forms/admin.py
+++ b/servo/forms/admin.py
@@ -95,15 +95,6 @@ class GsxAccountForm(forms.ModelForm):
class Meta:
model = GsxAccount
exclude = []
- widgets = {'password': forms.PasswordInput}
-
- def clean(self):
- cd = super(GsxAccountForm, self).clean()
- # Don't save empty passwords
- if cd['password'] == '':
- del cd['password']
-
- return cd
class GroupForm(forms.ModelForm):
@@ -365,11 +356,30 @@ class SettingsForm(BaseForm):
gsx_account = forms.ModelChoiceField(
required=False,
- label=_('Default GSX account'),
+ label=_('Default account'),
queryset=GsxAccount.objects.all(),
help_text=_('Use this GSX account before and order is assigned to a queue')
)
+ gsx_cert = forms.FileField(
+ required=False,
+ label=_('SSL certificate'),
+ help_text=_('SSL client certificate for GSX connections')
+ )
+
+ gsx_privkey = forms.FileField(
+ required=False,
+ label=_('SSL private key'),
+ help_text=_('SSL private key for certificate')
+ )
+
+ gsx_keypass = forms.CharField(
+ required=False,
+ widget=forms.PasswordInput,
+ label=_('Private key passphrase'),
+ help_text=_('Passphrase for private key')
+ )
+
pct_margin = forms.CharField(
required=False,
max_length=128,
@@ -523,17 +533,38 @@ class SettingsForm(BaseForm):
if re.match('^\d[\-=;\d]*\d$', margin):
return margin
- raise forms.ValidationError(_('Invalid margin %'))
+ raise forms.ValidationError(_('Invalid margin format'))
def save(self, *args, **kwargs):
config = dict()
+ from django.conf import settings
+
+ if self.cleaned_data.get('gsx_cert'):
+ f = self.cleaned_data['gsx_cert']
+ with open(settings.GSX_CERT, 'wb+') as d:
+ for chunk in f.chunks():
+ d.write(chunk)
+
+ if self.cleaned_data.get('gsx_privkey'):
+ f = self.cleaned_data['gsx_privkey']
+ with open(settings.GSX_KEY, 'wb+') as d:
+ for chunk in f.chunks():
+ d.write(chunk)
+
+ if self.cleaned_data.get('gsx_keypass'):
+ import subprocess
+ keypass = self.cleaned_data['gsx_keypass']
+ subprocess.call(['openssl', 'rsa', '-passin',
+ 'pass:' + keypass,
+ '-in', settings.GSX_KEY,
+ '-out', settings.GSX_KEY])
if self.cleaned_data.get('company_logo'):
f = self.cleaned_data['company_logo']
target = 'uploads/logos/%s' % f.name
- with open(target, 'wb+') as destination:
+ with open(target, 'wb+') as d:
for chunk in f.chunks():
- destination.write(chunk)
+ d.write(chunk)
self.cleaned_data['company_logo'] = 'logos/%s' % f.name
else:
diff --git a/servo/templates/admin/settings.html b/servo/templates/admin/settings.html
index 15266b7..8ee85b1 100644
--- a/servo/templates/admin/settings.html
+++ b/servo/templates/admin/settings.html
@@ -10,6 +10,7 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">{% trans "General" %}</a></li>
<li><a href="#tab2" data-toggle="tab">{% trans "Stock" %}</a></li>
+ <li><a href="#tab7" data-toggle="tab">{% trans "GSX" %}</a></li>
<li><a href="#tab3" data-toggle="tab">{% trans "Outgoing Mail" %}</a></li>
<li><a href="#tab4" data-toggle="tab">{% trans "Incoming Mail" %}</a></li>
<li><a href="#tab5" data-toggle="tab">{% trans "Text Messages" %}</a></li>
@@ -19,7 +20,6 @@
<div class="tab-pane active" id="tab1">
{% include "form_field_snippet.html" with field=form.company_name %}
{% include "form_field_snippet.html" with field=form.company_logo %}
- {% include "form_field_snippet.html" with field=form.gsx_account %}
{% include "form_field_snippet.html" with field=form.terms_of_service %}
{% include "form_field_snippet.html" with field=form.autocomplete_repairs %}
</div>
@@ -38,6 +38,12 @@
</div>
</div>
</div>
+ <div class="tab-pane" id="tab7">
+ {% include "form_field_snippet.html" with field=form.gsx_account %}
+ {% include "form_field_snippet.html" with field=form.gsx_cert %}
+ {% include "form_field_snippet.html" with field=form.gsx_privkey %}
+ {% include "form_field_snippet.html" with field=form.gsx_keypass %}
+ </div>
<div class="tab-pane" id="tab3">
<fieldset>
{% include "form_field_snippet.html" with field=form.default_sender %}
diff --git a/settings.py b/settings.py
index 3e3c863..78290c0 100644
--- a/settings.py
+++ b/settings.py
@@ -243,3 +243,6 @@ ENABLE_RULES = True
TIMEZONE = 'Europe/Helsinki'
from local_settings import *
+
+os.environ['GSX_CERT'] = GSX_CERT
+os.environ['GSX_KEY'] = GSX_KEY \ No newline at end of file