From: Radek Czajka Date: Sat, 30 Mar 2019 22:23:33 +0000 (+0100) Subject: Nicer for admin. X-Git-Url: https://git.mdrn.pl/cas.git/commitdiff_plain/6e3dcb6d3a61a9dcd85dc5bf5e44c2d49a5a1cb3 Nicer for admin. --- diff --git a/src/accounts/apps.py b/src/accounts/apps.py new file mode 100644 index 0000000..c052eff --- /dev/null +++ b/src/accounts/apps.py @@ -0,0 +1,7 @@ +from django.apps import AppConfig +from django.utils.translation import ugettext_lazy as _ + + +class AccountsConfig(AppConfig): + name = 'accounts' + verbose_name = _('Accounts') diff --git a/src/accounts/locale/pl/LC_MESSAGES/django.po b/src/accounts/locale/pl/LC_MESSAGES/django.po index cd0ec48..3960e50 100644 --- a/src/accounts/locale/pl/LC_MESSAGES/django.po +++ b/src/accounts/locale/pl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-03-29 14:19+0100\n" +"POT-Creation-Date: 2019-03-30 22:52+0100\n" "PO-Revision-Date: 2019-03-29 14:15+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: \n" @@ -17,29 +17,33 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.0.6\n" -#: templates/account/base.html:8 +#: templates/account/base.html:9 msgid "Change at Gravatar.com" msgstr "Zmień na Gravatar.com" -#: templates/account/base.html:10 templates/account/profile.html:5 +#: templates/account/base.html:11 templates/account/profile.html:5 #: templates/account/profile.html:16 msgid "Your profile" msgstr "Twój profil" -#: templates/account/base.html:11 +#: templates/account/base.html:12 #: templates/registration/password_change_done.html:14 msgid "Password change" msgstr "" -#: templates/account/base.html:12 +#: templates/account/base.html:13 msgid "E-mail" msgstr "E-mail" -#: templates/account/base.html:13 +#: templates/account/base.html:16 msgid "SSH keys" msgstr "Klucze SSH" -#: templates/account/base.html:15 +#: templates/account/base.html:21 +msgid "Administration" +msgstr "" + +#: templates/account/base.html:23 msgid "Logout" msgstr "Wyloguj" diff --git a/src/accounts/templates/account/base.html b/src/accounts/templates/account/base.html index 18aa501..9cdc8ee 100644 --- a/src/accounts/templates/account/base.html +++ b/src/accounts/templates/account/base.html @@ -16,6 +16,10 @@

{% trans "SSH keys" %}

{% endif %} {% endblock %} + + {% if request.user.is_staff %} +

{% trans "Administration" %}

+ {% endif %}

{% trans "Logout" %}

diff --git a/src/cas/settings.py b/src/cas/settings.py index d660614..ac904f3 100644 --- a/src/cas/settings.py +++ b/src/cas/settings.py @@ -83,9 +83,9 @@ LOCALE_PATHS = ( ) INSTALLED_APPS = ( - 'accounts', - 'services', - 'ssh_keys', + 'accounts.apps.AccountsConfig', + 'services.apps.ServicesConfig', + 'ssh_keys.apps.SshKeysConfig', 'cas_provider', 'django_gravatar', diff --git a/src/cas/static/css/main.css b/src/cas/static/css/main.css index 3894e43..134f3bf 100644 --- a/src/cas/static/css/main.css +++ b/src/cas/static/css/main.css @@ -133,3 +133,7 @@ footer, #content_push { .menu img { box-shadow: 0 0 .2em black; } + +code.key { + word-wrap: break-word; +} diff --git a/src/services/apps.py b/src/services/apps.py index e40a94f..3c1815d 100644 --- a/src/services/apps.py +++ b/src/services/apps.py @@ -1,5 +1,7 @@ from django.apps import AppConfig +from django.utils.translation import ugettext_lazy as _ class ServicesConfig(AppConfig): name = 'services' + verbose_name = _("Services") diff --git a/src/services/locale/pl/LC_MESSAGES/django.mo b/src/services/locale/pl/LC_MESSAGES/django.mo new file mode 100644 index 0000000..a4d68bc Binary files /dev/null and b/src/services/locale/pl/LC_MESSAGES/django.mo differ diff --git a/src/services/locale/pl/LC_MESSAGES/django.po b/src/services/locale/pl/LC_MESSAGES/django.po new file mode 100644 index 0000000..b1a376f --- /dev/null +++ b/src/services/locale/pl/LC_MESSAGES/django.po @@ -0,0 +1,57 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-03-30 23:12+0100\n" +"PO-Revision-Date: 2019-03-30 23:13+0100\n" +"Language: pl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n" +"%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n" +"%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n" +"Last-Translator: \n" +"Language-Team: \n" +"X-Generator: Poedit 2.0.6\n" + +#: apps.py:7 +msgid "Services" +msgstr "Serwisy" + +#: models.py:8 +msgid "name" +msgstr "nazwa" + +#: models.py:9 +msgid "URL" +msgstr "URL" + +#: models.py:10 +msgid "key" +msgstr "klucz" + +#: models.py:11 +msgid "uses SSH" +msgstr "używa SSH" + +#: models.py:12 +msgid "groups" +msgstr "grupy" + +#: models.py:13 +msgid "users" +msgstr "użytkownicy" + +#: models.py:17 +msgid "service" +msgstr "serwis" + +#: models.py:18 +msgid "services" +msgstr "serwisy" diff --git a/src/services/migrations/0002_auto_20190330_2220.py b/src/services/migrations/0002_auto_20190330_2220.py new file mode 100644 index 0000000..5542c91 --- /dev/null +++ b/src/services/migrations/0002_auto_20190330_2220.py @@ -0,0 +1,48 @@ +# Generated by Django 2.1.7 on 2019-03-30 22:20 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('services', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='service', + options={'ordering': ('name',), 'verbose_name': 'service', 'verbose_name_plural': 'services'}, + ), + migrations.AlterField( + model_name='service', + name='groups', + field=models.ManyToManyField(blank=True, to='auth.Group', verbose_name='groups'), + ), + migrations.AlterField( + model_name='service', + name='key', + field=models.CharField(blank=True, max_length=255, verbose_name='key'), + ), + migrations.AlterField( + model_name='service', + name='name', + field=models.CharField(max_length=255, verbose_name='name'), + ), + migrations.AlterField( + model_name='service', + name='url', + field=models.URLField(blank=True, verbose_name='URL'), + ), + migrations.AlterField( + model_name='service', + name='users', + field=models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL, verbose_name='users'), + ), + migrations.AlterField( + model_name='service', + name='uses_ssh', + field=models.BooleanField(default=False, verbose_name='uses SSH'), + ), + ] diff --git a/src/services/models.py b/src/services/models.py index 6e945ce..593eff2 100644 --- a/src/services/models.py +++ b/src/services/models.py @@ -1,18 +1,21 @@ from django.conf import settings from django.contrib.auth.models import User from django.db import models +from django.utils.translation import ugettext_lazy as _ class Service(models.Model): - name = models.CharField(max_length=255) - url = models.URLField(blank=True) - key = models.CharField(max_length=255, blank=True) - uses_ssh = models.BooleanField(default=False) - groups = models.ManyToManyField('auth.Group', blank=True) - users = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True) + name = models.CharField(_('name'), max_length=255) + url = models.URLField(_('URL'), blank=True) + key = models.CharField(_('key'), max_length=255, blank=True) + uses_ssh = models.BooleanField(_('uses SSH'), default=False) + groups = models.ManyToManyField('auth.Group', verbose_name=_('groups'), blank=True) + users = models.ManyToManyField(settings.AUTH_USER_MODEL, verbose_name=_('users'), blank=True) class Meta: ordering = ('name', ) + verbose_name = _('service') + verbose_name_plural = _('services') def __str__(self): return self.name diff --git a/src/ssh_keys/apps.py b/src/ssh_keys/apps.py index 6663b50..f49fcb4 100644 --- a/src/ssh_keys/apps.py +++ b/src/ssh_keys/apps.py @@ -1,5 +1,7 @@ from django.apps import AppConfig +from django.utils.translation import ugettext_lazy as _ class SshKeysConfig(AppConfig): name = 'ssh_keys' + verbose_name = _('SSH keys') diff --git a/src/ssh_keys/locale/pl/LC_MESSAGES/django.mo b/src/ssh_keys/locale/pl/LC_MESSAGES/django.mo new file mode 100644 index 0000000..2268d5a Binary files /dev/null and b/src/ssh_keys/locale/pl/LC_MESSAGES/django.mo differ diff --git a/src/ssh_keys/locale/pl/LC_MESSAGES/django.po b/src/ssh_keys/locale/pl/LC_MESSAGES/django.po new file mode 100644 index 0000000..29bf9f8 --- /dev/null +++ b/src/ssh_keys/locale/pl/LC_MESSAGES/django.po @@ -0,0 +1,71 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-03-30 23:22+0100\n" +"PO-Revision-Date: 2019-03-30 23:22+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: pl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n" +"%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n" +"%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n" +"X-Generator: Poedit 2.0.6\n" + +#: apps.py:7 models.py:15 templates/ssh_keys/sshkey_list.html:13 +msgid "SSH keys" +msgstr "Klucze SSH" + +#: models.py:7 +msgid "user" +msgstr "użytkownik" + +#: models.py:8 +msgid "key" +msgstr "klucz" + +#: models.py:9 +msgid "comment" +msgstr "komentarz" + +#: models.py:10 +msgid "created at" +msgstr "utworzony" + +#: models.py:14 +msgid "SSH key" +msgstr "klucz SSH" + +#: templates/ssh_keys/sshkey_add.html:6 +msgid "Add SSH key" +msgstr "Dodaj klucz SSH" + +#: templates/ssh_keys/sshkey_add.html:12 templates/ssh_keys/sshkey_list.html:27 +msgid "Add" +msgstr "Dodaj" + +#: templates/ssh_keys/sshkey_confirm_delete.html:6 +msgid "Confirm deleting an SSH key" +msgstr "Potwierdź usunięcie klucza SSH" + +#: templates/ssh_keys/sshkey_confirm_delete.html:8 +msgid "Are you sure you want to delete this key?" +msgstr "Czy na pewno chcesz usunąć ten klucz?" + +#: templates/ssh_keys/sshkey_confirm_delete.html:14 +#: templates/ssh_keys/sshkey_list.html:18 +msgid "Added at" +msgstr "Dodano" + +#: templates/ssh_keys/sshkey_confirm_delete.html:17 +#: templates/ssh_keys/sshkey_list.html:20 +msgid "Delete" +msgstr "Usuń" diff --git a/src/ssh_keys/migrations/0002_auto_20190330_2220.py b/src/ssh_keys/migrations/0002_auto_20190330_2220.py new file mode 100644 index 0000000..afb4a38 --- /dev/null +++ b/src/ssh_keys/migrations/0002_auto_20190330_2220.py @@ -0,0 +1,39 @@ +# Generated by Django 2.1.7 on 2019-03-30 22:20 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ssh_keys', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='sshkey', + options={'ordering': ['created_at'], 'verbose_name': 'SSH key', 'verbose_name_plural': 'SSH keys'}, + ), + migrations.AddField( + model_name='sshkey', + name='comment', + field=models.CharField(blank=True, max_length=255, verbose_name='comment'), + ), + migrations.AlterField( + model_name='sshkey', + name='created_at', + field=models.DateTimeField(auto_now_add=True, verbose_name='created at'), + ), + migrations.AlterField( + model_name='sshkey', + name='key', + field=models.TextField(verbose_name='key'), + ), + migrations.AlterField( + model_name='sshkey', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='user'), + ), + ] diff --git a/src/ssh_keys/models.py b/src/ssh_keys/models.py index 960a5ec..18b887e 100644 --- a/src/ssh_keys/models.py +++ b/src/ssh_keys/models.py @@ -1,11 +1,22 @@ from django.conf import settings from django.db import models +from django.utils.translation import ugettext_lazy as _ class SSHKey(models.Model): - user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) - key = models.TextField() - created_at = models.DateTimeField(auto_now_add=True) + user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, verbose_name=_('user')) + key = models.TextField(_('key')) + comment = models.CharField(_('comment'), max_length=255, blank=True) + created_at = models.DateTimeField(_('created at'), auto_now_add=True) class Meta: ordering = ['created_at'] + verbose_name = _('SSH key') + verbose_name_plural = _('SSH keys') + + def __str__(self): + return self.comment + + def save(self, *args, **kwargs): + self.comment = self.key.rsplit()[-1][:255] + return super().save(*args, **kwargs) diff --git a/src/ssh_keys/templates/ssh_keys/sshkey_confirm_delete.html b/src/ssh_keys/templates/ssh_keys/sshkey_confirm_delete.html index 7f3d109..c1217d1 100644 --- a/src/ssh_keys/templates/ssh_keys/sshkey_confirm_delete.html +++ b/src/ssh_keys/templates/ssh_keys/sshkey_confirm_delete.html @@ -5,7 +5,7 @@ {% block accounts-content %}

{% trans "Confirm deleting an SSH key" %}

-

Are you sure you want to delete this key?

+

{% trans "Are you sure you want to delete this key?" %}

{% csrf_token %} diff --git a/src/ssh_keys/templates/ssh_keys/sshkey_list.html b/src/ssh_keys/templates/ssh_keys/sshkey_list.html index a4f5155..9dea954 100644 --- a/src/ssh_keys/templates/ssh_keys/sshkey_list.html +++ b/src/ssh_keys/templates/ssh_keys/sshkey_list.html @@ -14,7 +14,7 @@ {% for key in object_list %}

- {{ key.key }}
+ {{ key.key }}
{% trans "Added at" %} {{ key.created_at }}
{% trans "Delete" %}