gitweb: Minor fixes after review

- Since Wiki Commons and Icons project seems to be referring to each other for
  license about the git icon, point to the upstream git as source for copyright.

- Rename the is_running() method so that it won't clash with the semantics of
  is_running method in other components.

- Fix incorrect call to have_public_repos() in is_enabled() method for gitweb
  auth configuration.

- Use {{ block.super }} to avoid repeating inherited block.

- Send the repository data as context data rather than form data in AppView.
  This seems more appropriate.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2019-10-19 15:29:08 -07:00
parent 1b9dea4033
commit 8d4614c3e2
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
4 changed files with 14 additions and 23 deletions

6
debian/copyright vendored
View File

@ -76,9 +76,9 @@ License: CC-BY-SA-3.0 or GPL-3+
Files: static/themes/default/icons/gitweb.png Files: static/themes/default/icons/gitweb.png
static/themes/default/icons/gitweb.svg static/themes/default/icons/gitweb.svg
Copyright: Git Copyright: 2010 Git Authors
Comment: https://commons.wikimedia.org/wiki/File:Git_icon_2007.svg Comment: https://github.com/git/git/blob/master/gitweb/static/git-logo.png
License: GPL-2+ License: GPL-2
Files: static/themes/default/icons/google-play.png Files: static/themes/default/icons/google-play.png
Copyright: Chameleon Design (https://thenounproject.com/Chamedesign/) Copyright: Chameleon Design (https://thenounproject.com/Chamedesign/)

View File

@ -127,14 +127,14 @@ class GitwebApp(app_module.App):
def _enable_public_access(self): def _enable_public_access(self):
"""Allow Gitweb app to be accessed by anyone with access.""" """Allow Gitweb app to be accessed by anyone with access."""
if self.auth_webserver.is_running(): if self.auth_webserver.is_conf_enabled():
self.auth_webserver.disable() self.auth_webserver.disable()
self.set_shortcut_login_required(False) self.set_shortcut_login_required(False)
def _disable_public_access(self): def _disable_public_access(self):
"""Allow Gitweb app to be accessed by logged-in users only.""" """Allow Gitweb app to be accessed by logged-in users only."""
if not self.auth_webserver.is_running(): if not self.auth_webserver.is_conf_enabled():
self.auth_webserver.enable() self.auth_webserver.enable()
self.set_shortcut_login_required(True) self.set_shortcut_login_required(True)
@ -143,13 +143,13 @@ class GitwebApp(app_module.App):
class GitwebWebserverAuth(Webserver): class GitwebWebserverAuth(Webserver):
"""Component to handle Gitweb authentication webserver configuration.""" """Component to handle Gitweb authentication webserver configuration."""
def is_running(self): def is_conf_enabled(self):
"""Check whether Gitweb authentication webserver is running""" """Check whether Gitweb authentication configuration is enabled."""
return super().is_enabled() return super().is_enabled()
def is_enabled(self): def is_enabled(self):
"""Return if configuration is enabled or public access is enabled.""" """Return if configuration is enabled or public access is enabled."""
return app.have_public_repos or super().is_enabled() return app.have_public_repos() or super().is_enabled()
def init(): def init():

View File

@ -47,16 +47,7 @@
<h2>{{ title }}</h2> <h2>{{ title }}</h2>
{% block configuration %} {% block configuration %}
<h3>{% trans "Configuration" %}</h3> {{ block.super }}
<form class="form form-configuration" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary"
value="{% trans "Update setup" %}"/>
</form>
<h3>{% trans "Manage Repositories" %}</h3> <h3>{% trans "Manage Repositories" %}</h3>

View File

@ -45,12 +45,12 @@ class GitwebAppView(views.AppView):
show_status_block = False show_status_block = False
template_name = 'gitweb_configure.html' template_name = 'gitweb_configure.html'
def get_initial(self): def get_context_data(self, *args, **kwargs):
"""Return the status of the service to fill in the form.""" """Add repositories to the context data."""
initial = super().get_initial() context = super().get_context_data(*args, **kwargs)
gitweb.app.update_repo_list() gitweb.app.update_repo_list()
initial['repos'] = gitweb.app.repos context['repos'] = gitweb.app.repos
return initial return context
class CreateRepoView(SuccessMessageMixin, FormView): class CreateRepoView(SuccessMessageMixin, FormView):