From: Magnus Hagander Date: Tue, 22 Oct 2019 12:34:40 +0000 (+0200) Subject: Switch backend interface to boostrap X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=32636d6564c1b5bc87c84011a369b2198d4e05fd;p=pggit.git Switch backend interface to boostrap Make it look less bad and opens up for some further improvements --- diff --git a/gitadmin/gitadmin/adm/migrations/0001_initial.py b/gitadmin/gitadmin/adm/migrations/0001_initial.py index 31c292c..60046d6 100644 --- a/gitadmin/gitadmin/adm/migrations/0001_initial.py +++ b/gitadmin/gitadmin/adm/migrations/0001_initial.py @@ -65,7 +65,7 @@ class Migration(migrations.Migration): name='RepositoryPermission', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('userid', models.CharField(max_length=255)), + ('userid', models.CharField(max_length=255, verbose_name="User id")), ('level', models.IntegerField(default=0, verbose_name='Permission', choices=[(0, 'Read'), (1, 'Write'), (2, 'Owner')])), ('repository', models.ForeignKey(to='adm.Repository', db_column='repository')), ], diff --git a/gitadmin/gitadmin/adm/models.py b/gitadmin/gitadmin/adm/models.py index d2daa9e..f7245e4 100644 --- a/gitadmin/gitadmin/adm/models.py +++ b/gitadmin/gitadmin/adm/models.py @@ -45,7 +45,7 @@ class Repository(models.Model): verbose_name='Remote repository') def ValidateOwnerPermissions(self, user): - if self.repositorypermission_set.filter(userid=user.username, level=2).count() != 1: + if not self.repositorypermission_set.filter(userid=user.username, level=2).exists(): raise Exception('You need owner permissions to do that!') def __str__(self): @@ -58,7 +58,7 @@ class Repository(models.Model): class RepositoryPermission(models.Model): repository = models.ForeignKey(Repository, db_column='repository') - userid = models.CharField(max_length=255, blank=False) + userid = models.CharField(max_length=255, blank=False, verbose_name="User id") level = models.IntegerField(default=0, verbose_name='Permission', choices=PERMISSION_CHOICES) @property diff --git a/gitadmin/gitadmin/adm/templates/base.html b/gitadmin/gitadmin/adm/templates/base.html index bdbbf49..ddd85e7 100644 --- a/gitadmin/gitadmin/adm/templates/base.html +++ b/gitadmin/gitadmin/adm/templates/base.html @@ -1,31 +1,50 @@ - - - - PostgreSQL Git Repository - - - - + + + + + + + + + -
-
-
PostgreSQL
-
The world's most advanced open source database
-
-
-
-{%if user.is_authenticated %} -
Log out
-{%endif%} +
+
+
+ +
+
+
+
{%if missing_sshkey %} -

Note! Your ssh key has not yet been registered with the system, or it has not yet replicated -from the main server. Please upload your keys using the -community account system.

+
Your ssh key has not yet been registered with the system, +or it has not yet replicated from the main server. Please upload your keys using the +community account system. +
+{%endif%} +{%block content%}{%endblock%} +
+
+
+
+ Log out +{%if user.is_superuser %} + Django Admin {%endif%} -{% block content %} {% endblock %} -
-
+
+
+
+ + + + diff --git a/gitadmin/gitadmin/adm/templates/deleterepo.html b/gitadmin/gitadmin/adm/templates/deleterepo.html index 4e35b4f..29306cb 100644 --- a/gitadmin/gitadmin/adm/templates/deleterepo.html +++ b/gitadmin/gitadmin/adm/templates/deleterepo.html @@ -5,11 +5,12 @@

Are you sure you want to delete this repository? The repository contents will also be deleted!

- -{{form}} -
- +{% csrf_token %} +{%for field in form%} +{%include "form_field.html"%} +{%endfor%} +
-Back +Back {%endblock%} diff --git a/gitadmin/gitadmin/adm/templates/form_field.html b/gitadmin/gitadmin/adm/templates/form_field.html new file mode 100644 index 0000000..626d6f1 --- /dev/null +++ b/gitadmin/gitadmin/adm/templates/form_field.html @@ -0,0 +1,21 @@ +{%load formutil%} +{%if not field.is_hidden%} +
+ {{field|label_class:"col-sm-3 col-form-label"}} +
+ {%if field.errors %} + {%for e in field.errors%} +
{{e}}
+ {%endfor%} + {%endif%} +{%if field|ischeckbox%} +
{{field|field_class:"form-check-input"}}
+{%else%} +{{field|field_class:"form-control"}} +{%endif%} +{%if field.help_text%}{{field.help_text|safe}}{%endif%} +
+
+ {%else%}{# field.is_hidden #} +{{field}} + {%endif%} diff --git a/gitadmin/gitadmin/adm/templates/index.html b/gitadmin/gitadmin/adm/templates/index.html index c8e8f29..0fe98f2 100644 --- a/gitadmin/gitadmin/adm/templates/index.html +++ b/gitadmin/gitadmin/adm/templates/index.html @@ -1,21 +1,24 @@ {%extends "base.html"%} {%block content%}

You have access to the following git repositories:

- +
- - + + {% for r in repos %} - - - + + + {% endfor %}
Name DescriptiongitwebgitserveGitwebGit Approved
{%if r.perm %}{{r.name}}{%else%}{{r.name}}{%endif%} {{r.description}}{%if r.web %}url{%endif%}{%if r.anonymous %}url{%endif%}{{r.approved|yesno:"Yes,No"}}{%if r.web %}Gitweb{%else%}Disabled{%endif%} + ssh + {%if r.anonymous %}
http{%endif%} +
{{r.approved|yesno:"Yes,No"}}
@@ -30,9 +33,9 @@ the naming conversions as listed on the help page.

To request a new project, enter a name here. The name has to be 5-64 characters long and contain only lowercase letters and numbers.

-
- - + + +
{%endblock%} diff --git a/gitadmin/gitadmin/adm/templates/repoview.html b/gitadmin/gitadmin/adm/templates/repoview.html index 31a4fc3..b1112e8 100644 --- a/gitadmin/gitadmin/adm/templates/repoview.html +++ b/gitadmin/gitadmin/adm/templates/repoview.html @@ -1,12 +1,15 @@ {%extends "base.html"%} {%block content%} -

Repository: {{repo.name}}

+

Repository: {{repo.name}}

{% if not repo.approved %} -

This repository has not yet been approved. This means you cannot access it through git or web yet. +

This repository has not yet been approved.

+

+This means you cannot access it through git or web yet. You can still update the description and set permissions - they will all start working automatically when the repository is approved. Until approval you can also set it up to clone another repository -automatically upon creation.

+automatically upon creation. +

{%endif%} {% if form_saved_at %}

Your changes were successfully saved at {{form_saved_at|date:"Y-m-d H:i:s"}}.

@@ -15,24 +18,30 @@ automatically upon creation.

Error: The submitted form contains errors and could not be saved.

{%endif%}
- -{{form}} -
-

Delete this repository

+{% csrf_token %} +{%if form.non_field_errors%} +
{{form.non_field_errors}}
+{%endif%} +{%for field in form%} +{%include "form_field.html"%} +{%endfor%}

Permissions

{{formset.management_form}} - -{% for f in formset.forms %} + +
+{% for form in formset.forms %} - + {%for field in form %} + + {%endfor%} {% endfor %}
- {{f.as_p}} - {%include "form_field.html"%}
- +
-Back + +Delete this repository +Back {%endblock%} diff --git a/gitadmin/gitadmin/adm/templatetags/__init__.py b/gitadmin/gitadmin/adm/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gitadmin/gitadmin/adm/templatetags/alertmap.py b/gitadmin/gitadmin/adm/templatetags/alertmap.py new file mode 100644 index 0000000..c1cd5fd --- /dev/null +++ b/gitadmin/gitadmin/adm/templatetags/alertmap.py @@ -0,0 +1,17 @@ +from django.template.defaultfilters import stringfilter +from django import template + +register = template.Library() + + +@register.filter(name='alertmap') +@stringfilter +def alertmap(value): + if value == 'error': + return 'alert-danger' + elif value == 'warning': + return 'alert-warning' + elif value == 'success': + return 'alert-success' + else: + return 'alert-info' diff --git a/gitadmin/gitadmin/adm/templatetags/formutil.py b/gitadmin/gitadmin/adm/templatetags/formutil.py new file mode 100644 index 0000000..37f7b48 --- /dev/null +++ b/gitadmin/gitadmin/adm/templatetags/formutil.py @@ -0,0 +1,22 @@ +from django import template + +register = template.Library() + + +@register.filter(is_safe=True) +def label_class(value, arg): + return value.label_tag(attrs={'class': arg}) + + +@register.filter(is_safe=True) +def field_class(value, arg): + prevclass = value.field.widget.attrs.get('class', '') + if prevclass: + newclass = "{0} {1}".format(arg, prevclass) + else: + newclass = arg + return value.as_widget(attrs={"class": newclass}) + +@register.filter(is_safe=True) +def ischeckbox(obj): + return obj.field.widget.__class__.__name__ in ("CheckboxInput", "CheckboxSelectMultiple") and not getattr(obj.field, 'regular_field', False) diff --git a/gitadmin/gitadmin/adm/views.py b/gitadmin/gitadmin/adm/views.py index ef1ad3c..83ee27b 100644 --- a/gitadmin/gitadmin/adm/views.py +++ b/gitadmin/gitadmin/adm/views.py @@ -60,7 +60,6 @@ def help(request): def editrepo(request, repoid): repo = get_object_or_404(Repository, repoid=repoid) repo.ValidateOwnerPermissions(request.user) - savedat = None form = None formfactory = inlineformset_factory(Repository, RepositoryPermission, extra=1, fields=['userid', 'level']) @@ -95,9 +94,7 @@ def editrepo(request, repoid): form.save() formset.save() - savedat = datetime.datetime.now() - # Get a new copy of the repository to make sure it refreshes! - repo = get_object_or_404(Repository, repoid=repoid) + return HttpResponseRedirect("../../") except FormIsNotValid: # Just continue as if the form wasn't valid, expect the caller # to have set the required error fields @@ -118,7 +115,6 @@ def editrepo(request, repoid): 'formset': formset, 'repo': repo, 'repoperm': perm, - 'form_saved_at': savedat, }) diff --git a/gitadmin/gitadmin/static/pggit.css b/gitadmin/gitadmin/static/pggit.css index caf2312..e4045c1 100644 --- a/gitadmin/gitadmin/static/pggit.css +++ b/gitadmin/gitadmin/static/pggit.css @@ -1,50 +1,11 @@ body { - font-family: verdana, sans-serif; - color: #000000; - background-color: #ffffff; - margin: 0 0 0 0; - padding: 0 0 0 0; - font-size: 13px; -} - -div#pggitHeader { - width: 100%; - background: url(https://www.postgresql.org/layout/images/hdr_fill.png); - padding: 0 0 0 0; - height: 80px; - margin: 5px 0 2px 0; -} - -div#pggitWrap { - margin-left: 20px; - margin-right: 20px; -} - -div#pggitWrap img { - /* applies to all images */ - border: none; -} - -div#pggitMain { - width: 100%; -} - -div.fl { float: left; border: none; text-align: left; } -div.fr { float: right; } -div.cb { clear: both; } -div.cl { clear: left; } - -a:link { color:#0085B0; text-decoration: underline; } -a:visited { color:#004E66; text-decoration: underline; } -a:active { color:#0085B0; text-decoration: underline; } -a:hover { color:#000000; text-decoration: underline; } - + padding-top: 4rem; -td.rowform p { - display: inline; - padding-right: 20px; + font-weight: 400; + color: #515151; + font-size: 11.5pt; } -table.leftalign tr th { - text-align: left; +.table-nonfluid { + width: auto !important; }