aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-08-14 15:21:51 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-08-14 15:21:51 +0300
commitf38838154defe15e0b2d043c19f6985484993423 (patch)
tree10d2f9339e7b076720d85cd5f2eea84c3b8cd16d /servo
parent47564afcc25b48d42c76613899b96b9826b3cfc4 (diff)
downloadServo-f38838154defe15e0b2d043c19f6985484993423.tar.gz
Servo-f38838154defe15e0b2d043c19f6985484993423.tar.bz2
Servo-f38838154defe15e0b2d043c19f6985484993423.zip
Added GSX cert settings
Diffstat (limited to 'servo')
-rw-r--r--servo/forms/admin.py57
-rw-r--r--servo/templates/admin/settings.html8
2 files changed, 51 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 %}