From d2d96e99515a8f5af1e2ff77892eda91572591de Mon Sep 17 00:00:00 2001 From: Siarhei Puhach Date: Thu, 6 Jul 2017 14:18:22 +0300 Subject: [PATCH] Added private_key field to UserHostingkey model, some html updates --- hosting/forms.py | 2 +- .../0041_userhostingkey_private_key.py | 20 +++++++++++++++++++ hosting/models.py | 1 + hosting/templates/hosting/user_keys.html | 19 +++++++++++------- hosting/views.py | 13 ++++++++++-- 5 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 hosting/migrations/0041_userhostingkey_private_key.py diff --git a/hosting/forms.py b/hosting/forms.py index e5a14d48..c39d3b4e 100644 --- a/hosting/forms.py +++ b/hosting/forms.py @@ -71,7 +71,7 @@ class UserHostingKeyForm(forms.ModelForm): user = forms.models.ModelChoiceField(queryset=CustomUser.objects.all(), required=False, widget=forms.HiddenInput()) name = forms.CharField(required=False, widget=forms.TextInput( - attrs={'class': 'form_key_name', 'placeholder': 'Give a name to your key',})) + attrs={'class': 'form_key_name', 'placeholder': 'Give a name to your key'})) def __init__(self, *args, **kwargs): self.request = kwargs.pop("request") diff --git a/hosting/migrations/0041_userhostingkey_private_key.py b/hosting/migrations/0041_userhostingkey_private_key.py new file mode 100644 index 00000000..0edb71d0 --- /dev/null +++ b/hosting/migrations/0041_userhostingkey_private_key.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-07-06 09:06 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0040_hostingplan'), + ] + + operations = [ + migrations.AddField( + model_name='userhostingkey', + name='private_key', + field=models.FileField(blank=True, upload_to='private_keys'), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index bb53589d..88386913 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -101,6 +101,7 @@ class HostingOrder(AssignPermissionsMixin, models.Model): class UserHostingKey(models.Model): user = models.ForeignKey(CustomUser) public_key = models.TextField() + private_key = models.FileField(upload_to='private_keys', blank=True) created_at = models.DateTimeField(auto_now_add=True) name = models.CharField(max_length=100) diff --git a/hosting/templates/hosting/user_keys.html b/hosting/templates/hosting/user_keys.html index 0fe50a6f..ea2bbacf 100644 --- a/hosting/templates/hosting/user_keys.html +++ b/hosting/templates/hosting/user_keys.html @@ -40,9 +40,9 @@