Nicer for admin.
authorRadek Czajka <rczajka@rczajka.pl>
Sat, 30 Mar 2019 22:23:33 +0000 (23:23 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Sat, 30 Mar 2019 22:23:33 +0000 (23:23 +0100)
17 files changed:
src/accounts/apps.py [new file with mode: 0644]
src/accounts/locale/pl/LC_MESSAGES/django.po
src/accounts/templates/account/base.html
src/cas/settings.py
src/cas/static/css/main.css
src/services/apps.py
src/services/locale/pl/LC_MESSAGES/django.mo [new file with mode: 0644]
src/services/locale/pl/LC_MESSAGES/django.po [new file with mode: 0644]
src/services/migrations/0002_auto_20190330_2220.py [new file with mode: 0644]
src/services/models.py
src/ssh_keys/apps.py
src/ssh_keys/locale/pl/LC_MESSAGES/django.mo [new file with mode: 0644]
src/ssh_keys/locale/pl/LC_MESSAGES/django.po [new file with mode: 0644]
src/ssh_keys/migrations/0002_auto_20190330_2220.py [new file with mode: 0644]
src/ssh_keys/models.py
src/ssh_keys/templates/ssh_keys/sshkey_confirm_delete.html
src/ssh_keys/templates/ssh_keys/sshkey_list.html

diff --git a/src/accounts/apps.py b/src/accounts/apps.py
new file mode 100644 (file)
index 0000000..c052eff
--- /dev/null
@@ -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')
index cd0ec48..3960e50 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
 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 <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
 "Language-Team: \n"
 "PO-Revision-Date: 2019-03-29 14:15+0100\n"
 "Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
 "Language-Team: \n"
@@ -17,29 +17,33 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "X-Generator: Poedit 2.0.6\n"
 
 "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"
 
 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/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/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"
 
 msgid "E-mail"
 msgstr "E-mail"
 
-#: templates/account/base.html:13
+#: templates/account/base.html:16
 msgid "SSH keys"
 msgstr "Klucze SSH"
 
 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"
 
 msgid "Logout"
 msgstr "Wyloguj"
 
index 18aa501..9cdc8ee 100644 (file)
         <p><a {% if menu == 'ssh' %}class="active"{% endif %} href="{% url 'ssh_keys' %}">{% trans "SSH keys" %}</a></p>
       {% endif %}
     {% endblock %}
         <p><a {% if menu == 'ssh' %}class="active"{% endif %} href="{% url 'ssh_keys' %}">{% trans "SSH keys" %}</a></p>
       {% endif %}
     {% endblock %}
+
+    {% if request.user.is_staff %}
+      <p><a href='/admin/'>{% trans "Administration" %}</a></p>
+    {% endif %}
     <p><a href="{% url 'cas_logout' %}">{% trans "Logout" %}</a></p>
   </aside>
 
     <p><a href="{% url 'cas_logout' %}">{% trans "Logout" %}</a></p>
   </aside>
 
index d660614..ac904f3 100644 (file)
@@ -83,9 +83,9 @@ LOCALE_PATHS = (
 )
 
 INSTALLED_APPS = (
 )
 
 INSTALLED_APPS = (
-    'accounts',
-    'services',
-    'ssh_keys',
+    'accounts.apps.AccountsConfig',
+    'services.apps.ServicesConfig',
+    'ssh_keys.apps.SshKeysConfig',
 
     'cas_provider',
     'django_gravatar',
 
     'cas_provider',
     'django_gravatar',
index 3894e43..134f3bf 100644 (file)
@@ -133,3 +133,7 @@ footer, #content_push {
 .menu img {
     box-shadow: 0 0 .2em black;
 }
 .menu img {
     box-shadow: 0 0 .2em black;
 }
+
+code.key {
+    word-wrap: break-word;
+}
index e40a94f..3c1815d 100644 (file)
@@ -1,5 +1,7 @@
 from django.apps import AppConfig
 from django.apps import AppConfig
+from django.utils.translation import ugettext_lazy as _
 
 
 class ServicesConfig(AppConfig):
     name = 'services'
 
 
 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 (file)
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 (file)
index 0000000..b1a376f
--- /dev/null
@@ -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 <EMAIL@ADDRESS>, 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 (file)
index 0000000..5542c91
--- /dev/null
@@ -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'),
+        ),
+    ]
index 6e945ce..593eff2 100644 (file)
@@ -1,18 +1,21 @@
 from django.conf import settings
 from django.contrib.auth.models import User
 from django.db import models
 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):
 
 
 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', )
 
     class Meta:
         ordering = ('name', )
+        verbose_name = _('service')
+        verbose_name_plural = _('services')
 
     def __str__(self):
         return self.name
 
     def __str__(self):
         return self.name
index 6663b50..f49fcb4 100644 (file)
@@ -1,5 +1,7 @@
 from django.apps import AppConfig
 from django.apps import AppConfig
+from django.utils.translation import ugettext_lazy as _
 
 
 class SshKeysConfig(AppConfig):
     name = 'ssh_keys'
 
 
 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 (file)
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 (file)
index 0000000..29bf9f8
--- /dev/null
@@ -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 <EMAIL@ADDRESS>, 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 (file)
index 0000000..afb4a38
--- /dev/null
@@ -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'),
+        ),
+    ]
index 960a5ec..18b887e 100644 (file)
@@ -1,11 +1,22 @@
 from django.conf import settings
 from django.db import models
 from django.conf import settings
 from django.db import models
+from django.utils.translation import ugettext_lazy as _
 
 
 class SSHKey(models.Model):
 
 
 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']
 
     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)
index 7f3d109..c1217d1 100644 (file)
@@ -5,7 +5,7 @@
 {% block accounts-content %}
 <h1>{% trans "Confirm deleting an SSH key" %}</h1>
 
 {% block accounts-content %}
 <h1>{% trans "Confirm deleting an SSH key" %}</h1>
 
-<p>Are you sure you want to delete this key?</p>
+<p>{% trans "Are you sure you want to delete this key?" %}</p>
 
 <form method="post">
   {% csrf_token %}
 
 <form method="post">
   {% csrf_token %}
index a4f5155..9dea954 100644 (file)
@@ -14,7 +14,7 @@
 
   {% for key in object_list %}
 <p>
 
   {% for key in object_list %}
 <p>
-  <code style='word-wrap:break-word'>{{ key.key }}</code><br>
+  <code class="key">{{ key.key }}</code><br>
   {% trans "Added at" %} {{ key.created_at }}<br>
   <a href="{% url 'ssh_keys_delete' key.id %}">
     {% trans "Delete" %}
   {% trans "Added at" %} {{ key.created_at }}<br>
   <a href="{% url 'ssh_keys_delete' key.id %}">
     {% trans "Delete" %}