diff --git a/hosting/forms.py b/hosting/forms.py index b48a52ef..e5a14d48 100644 --- a/hosting/forms.py +++ b/hosting/forms.py @@ -1,3 +1,5 @@ +import datetime + from django import forms from membership.models import CustomUser from django.contrib.auth import authenticate @@ -7,6 +9,10 @@ from django.utils.translation import ugettext_lazy as _ from .models import UserHostingKey +def generate_ssh_key_name(): + return 'dcl-generated-key-' + datetime.datetime.now().strftime('%m%d%y%H%M') + + class HostingUserLoginForm(forms.Form): email = forms.CharField(widget=forms.EmailInput()) @@ -64,7 +70,7 @@ class UserHostingKeyForm(forms.ModelForm): ) user = forms.models.ModelChoiceField(queryset=CustomUser.objects.all(), required=False, widget=forms.HiddenInput()) - name = forms.CharField(required=True, widget=forms.TextInput( + name = forms.CharField(required=False, widget=forms.TextInput( attrs={'class': 'form_key_name', 'placeholder': 'Give a name to your key',})) def __init__(self, *args, **kwargs): @@ -80,7 +86,8 @@ class UserHostingKeyForm(forms.ModelForm): def clean(self): cleaned_data = self.cleaned_data - + if not self.cleaned_data.get('name', ''): + self.cleaned_data['name'] = generate_ssh_key_name() if not cleaned_data.get('public_key'): private_key, public_key = UserHostingKey.generate_keys() cleaned_data.update({ diff --git a/hosting/static/hosting/css/user_keys.css b/hosting/static/hosting/css/user_keys.css index 416b9e44..4f8a27b7 100644 --- a/hosting/static/hosting/css/user_keys.css +++ b/hosting/static/hosting/css/user_keys.css @@ -1,3 +1,6 @@ +h2,h3,h4,h5{ + font-family: 'Lato-Light', sans-serif; +} .ssh-keys-table thead tr th, .ssh-keys-table tbody tr td{ color: #717274; @@ -97,29 +100,48 @@ display: flex; flex-direction: row; align-items: center; - justify-content: center; + justify-content: space-between; } -.choice-container div:first-of-type{ - border-right: 1px solid #c9c6c6; -} - .choice-container div{ padding-top: 30px; padding-bottom: 30px; display: flex; align-items: center; flex-direction: column; - width: 50%; + width: 49%; } .choice-container div h3{ margin: auto; width: 95%; text-align: center; + font-family: 'Lato-Light', sans-serif; } .choice-container div h3 img:hover{ cursor: pointer; } -.dashboard-container { +.choice-container div.choice-container-line{ + padding-top: 0; + padding-bottom: 0; + border: 1px solid #c9c6c6; + height: 250px; + width:1px; +} +@media screen and (max-width: 768px){ + .choice-container div.choice-container-line{ + display: none; + } + .choice-container{ + flex-direction: column; + } + .choice-container div{ + width: 100%; + } + .choice-container div h3 { + font-size: 16px; + } +} + +.dashboard-choice-container { max-width: 930px !important; } .choice-button{ @@ -128,14 +150,19 @@ border-radius: 0; color: white; margin-top: 70px; -} -.choice-button a{ - color: white; font-size: 20px; } +@media screen and (max-width: 768px){ + .choice-button{ + margin-top: 20px; + } +} .upload-btn{ background-color: #337ab7; } +.form_key_name{ + width:60%; +} .form_public_key, .form_key_name{ border:none; @@ -233,3 +260,6 @@ .form-ssh h3{ margin-bottom: 40px; } +.custom_form_button{ + border-radius: 0; +} diff --git a/hosting/templates/hosting/choice_ssh_keys.html b/hosting/templates/hosting/choice_ssh_keys.html index 7da48342..3882a988 100644 --- a/hosting/templates/hosting/choice_ssh_keys.html +++ b/hosting/templates/hosting/choice_ssh_keys.html @@ -2,7 +2,7 @@ {% load staticfiles bootstrap3 i18n %} {% block content %}