From 8df12a177456411229313e3aa585a9446e071141 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 13 Aug 2017 22:37:38 -0500 Subject: [PATCH] Add basic upgrades support, remove 'better' theme references --- rattail_demo/web/app.py | 5 ++-- rattail_demo/web/templates/base.mako | 4 ++-- rattail_demo/web/templates/menu.mako | 7 ++++-- rattail_demo/web/views/__init__.py | 4 +++- rattail_demo/web/views/upgrades.py | 35 ++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 rattail_demo/web/views/upgrades.py diff --git a/rattail_demo/web/app.py b/rattail_demo/web/app.py index a6716c8..38ea47d 100644 --- a/rattail_demo/web/app.py +++ b/rattail_demo/web/app.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- """ Pyramid web application """ @@ -15,9 +15,8 @@ def main(global_config, **settings): # set some defaults for PostgreSQL app.provide_postgresql_settings(settings) - # prefer demo templates over tailbone; use 'better' theme + # prefer demo templates over tailbone settings.setdefault('mako.directories', ['rattail_demo.web:templates', - 'tailbone:templates/themes/better', 'tailbone:templates',]) # make config objects diff --git a/rattail_demo/web/templates/base.mako b/rattail_demo/web/templates/base.mako index 09c3bf7..9083b95 100644 --- a/rattail_demo/web/templates/base.mako +++ b/rattail_demo/web/templates/base.mako @@ -1,5 +1,5 @@ -## -*- coding: utf-8 -*- -<%inherit file="tailbone:templates/themes/better/base.mako" /> +## -*- coding: utf-8; -*- +<%inherit file="tailbone:templates/base.mako" /> <%def name="global_title()">${"[STAGE] " if not request.rattail_config.production() else ''}Rattail Demo diff --git a/rattail_demo/web/templates/menu.mako b/rattail_demo/web/templates/menu.mako index 19c6c8d..912c6e0 100644 --- a/rattail_demo/web/templates/menu.mako +++ b/rattail_demo/web/templates/menu.mako @@ -1,4 +1,4 @@ -## -*- coding: utf-8 -*- +## -*- coding: utf-8; -*- <%def name="main_menu_items()"> @@ -110,7 +110,7 @@ % endif - % if request.has_any_perm('users.list', 'roles.list', 'emailprofiles.list', 'datasync.list', 'settings.list'): + % if request.has_any_perm('users.list', 'roles.list', 'emailprofiles.list', 'datasync.list', 'settings.list', 'upgrades.list'):
  • Admin
  • % endif diff --git a/rattail_demo/web/views/__init__.py b/rattail_demo/web/views/__init__.py index 5bd6d9a..7499874 100644 --- a/rattail_demo/web/views/__init__.py +++ b/rattail_demo/web/views/__init__.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- """ Web views """ @@ -11,6 +11,7 @@ def includeme(config): # core views config.include('rattail_demo.web.views.common') config.include('rattail_demo.web.views.auth') + config.include('tailbone.views.progress') # main table views config.include('tailbone.views.brands') @@ -30,6 +31,7 @@ def includeme(config): config.include('tailbone.views.stores') config.include('tailbone.views.subdepartments') config.include('rattail_demo.web.views.tempmon') + config.include('rattail_demo.web.views.upgrades') config.include('rattail_demo.web.views.users') config.include('tailbone.views.vendors') diff --git a/rattail_demo/web/views/upgrades.py b/rattail_demo/web/views/upgrades.py new file mode 100644 index 0000000..48961cc --- /dev/null +++ b/rattail_demo/web/views/upgrades.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8; -*- +""" +Upgrade views +""" + +from __future__ import unicode_literals, absolute_import + +import re + +from tailbone.views import upgrades as base + + +class UpgradeView(base.UpgradeView): + + def get_changelog_url(self, project, old_version, new_version): + + if project == 'rattail-demo': + if self.commit_hash_pattern.match(new_version): + if new_version == old_version: + return 'https://rattailproject.org/trac/log/rattail-demo/?rev={}&limit=100'.format( + new_version) + else: + return 'https://rattailproject.org/trac/log/rattail-demo/?rev={}&stop_rev={}&limit=100'.format( + new_version, old_version) + elif re.match(r'^\d+\.\d+\.\d+$', new_version): + return 'https://rattailproject.org/trac/browser/rattail-demo/CHANGES.rst?rev=v{}'.format( + new_version) + else: + return 'https://rattailproject.org/trac/browser/rattail-demo/CHANGES.rst' + + return super(UpgradeView, self).get_changelog_url(project, old_version, new_version) + + +def includeme(config): + UpgradeView.defaults(config)