From 8bf292ebac03b1cedb0f1b5e4428bdf29536f7cb Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 18 Nov 2014 23:00:24 -0600 Subject: [PATCH] Remove some more edbob cruft. --- tailbone/forms/renderers/common.py | 34 +-------------- tailbone/forms/renderers/products.py | 6 ++- tailbone/helpers.py | 10 ++--- tailbone/static/__init__.py | 10 ++--- tailbone/static/css/perms.css | 32 ++++++++++++++ tailbone/templates/progress.mako | 8 ++-- tailbone/templates/roles/crud.mako | 4 +- tailbone/util.py | 62 ++++++++++++++++++++++++++++ tailbone/views/auth.py | 24 ++++------- tailbone/views/batches/core.py | 17 ++++---- tailbone/views/crud.py | 8 ++-- tailbone/views/products.py | 1 - tailbone/views/reports.py | 7 ++-- tests/__init__.py | 37 ----------------- 14 files changed, 136 insertions(+), 124 deletions(-) create mode 100644 tailbone/static/css/perms.css create mode 100644 tailbone/util.py diff --git a/tailbone/forms/renderers/common.py b/tailbone/forms/renderers/common.py index 346db6a2..bf34d9c4 100644 --- a/tailbone/forms/renderers/common.py +++ b/tailbone/forms/renderers/common.py @@ -26,15 +26,11 @@ Common Field Renderers from __future__ import unicode_literals -import pytz -import humanize - import formalchemy from formalchemy.fields import FieldRenderer, SelectFieldRenderer, CheckBoxFieldRenderer from pyramid.renderers import render -from webhelpers.html import HTML -from rattail.time import timezone +from tailbone.util import pretty_datetime class AutocompleteFieldRenderer(FieldRenderer): @@ -80,34 +76,6 @@ class AutocompleteFieldRenderer(FieldRenderer): return unicode(value) -def pretty_datetime(config, value): - """ - Formats a datetime as a "pretty" human-readable string, with a tooltip - showing the ISO string value. - - :param config: Reference to a config object. - - :param value: A ``datetime.datetime`` instance. Note that if this instance - is not timezone-aware, its timezone is assumed to be UTC. - """ - if not value: - return '' - - # Make sure we're dealing with a tz-aware value. If we're given a naive - # value, we assume it to be local to the UTC timezone. - if not value.tzinfo: - value = pytz.utc.localize(value) - - # Convert value to local timezone, and make a naive copy. - local = timezone(config) - value = local.normalize(value.astimezone(local)) - naive_value = value.replace(tzinfo=None) - - return HTML.tag('span', - title=value.strftime('%Y-%m-%d %H:%M:%S %Z%z'), - c=humanize.naturaltime(naive_value)) - - class DateTimeFieldRenderer(formalchemy.DateTimeFieldRenderer): """ Custom date/time field renderer, which displays a "pretty" value in diff --git a/tailbone/forms/renderers/products.py b/tailbone/forms/renderers/products.py index 64e40bec..f7e3580b 100644 --- a/tailbone/forms/renderers/products.py +++ b/tailbone/forms/renderers/products.py @@ -30,7 +30,8 @@ from formalchemy import TextFieldRenderer from rattail.gpc import GPC from .common import AutocompleteFieldRenderer from webhelpers.html import literal -from edbob.pyramid.forms import pretty_datetime + +from tailbone.util import pretty_datetime __all__ = ['ProductFieldRenderer', 'GPCFieldRenderer', @@ -122,5 +123,6 @@ class PriceWithExpirationFieldRenderer(PriceFieldRenderer): if result: price = self.field.raw_value if price.ends: - result += '  (%s)' % pretty_datetime(price.ends, from_='utc') + result = '{0}  ({1})'.format( + result, pretty_datetime(self.request.rattail_config, price.ends)) return result diff --git a/tailbone/helpers.py b/tailbone/helpers.py index 8cbfb742..0c85c522 100644 --- a/tailbone/helpers.py +++ b/tailbone/helpers.py @@ -1,9 +1,8 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2012 Lance Edgar +# Copyright © 2010-2014 Lance Edgar # # This file is part of Rattail. # @@ -21,18 +20,19 @@ # along with Rattail. If not, see . # ################################################################################ - """ Template Context Helpers """ +from __future__ import unicode_literals + import datetime from decimal import Decimal from webhelpers.html import * from webhelpers.html.tags import * -from edbob.pyramid.forms import pretty_datetime +from tailbone.util import pretty_datetime def pretty_date(date): diff --git a/tailbone/static/__init__.py b/tailbone/static/__init__.py index 0f9c9c9e..7ea2cca3 100644 --- a/tailbone/static/__init__.py +++ b/tailbone/static/__init__.py @@ -1,9 +1,8 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2012 Lance Edgar +# Copyright © 2010-2014 Lance Edgar # # This file is part of Rattail. # @@ -21,13 +20,12 @@ # along with Rattail. If not, see . # ################################################################################ - """ Static Assets """ +from __future__ import unicode_literals + def includeme(config): - # TODO: Remove edbob. - config.include('edbob.pyramid.static') config.add_static_view('tailbone', 'tailbone:static') diff --git a/tailbone/static/css/perms.css b/tailbone/static/css/perms.css new file mode 100644 index 00000000..6a85e107 --- /dev/null +++ b/tailbone/static/css/perms.css @@ -0,0 +1,32 @@ + +/****************************** + * Permission Lists + ******************************/ + +div.field-wrapper.permissions div.field div.group { + margin-bottom: 10px; +} + +div.field-wrapper.permissions div.field div.group p { + font-weight: bold; +} + +div.field-wrapper.permissions div.field label { + float: none; + font-weight: normal; +} + +div.field-wrapper.permissions div.field label input { + margin-left: 15px; + margin-right: 10px; +} + +div.field-wrapper.permissions div.field div.group p.perm { + font-weight: normal; + margin-left: 15px; +} + +div.field-wrapper.permissions div.field div.group p.perm span { + font-family: monospace; + margin-right: 10px; +} diff --git a/tailbone/templates/progress.mako b/tailbone/templates/progress.mako index 8216dfc7..017b1535 100644 --- a/tailbone/templates/progress.mako +++ b/tailbone/templates/progress.mako @@ -4,10 +4,10 @@ Working... - ${h.javascript_link(request.static_url('edbob.pyramid:static/js/jquery.js'))} - ${h.javascript_link(request.static_url('edbob.pyramid:static/js/edbob.js'))} - ${h.stylesheet_link(request.static_url('edbob.pyramid:static/css/base.css'))} - ${h.stylesheet_link(request.static_url('edbob.pyramid:static/css/layout.css'))} + ${h.javascript_link(request.static_url('tailbone:static/js/lib/jquery-1.9.1.min.js'))} + ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.js'))} + ${h.stylesheet_link(request.static_url('tailbone:static/css/base.css'))} + ${h.stylesheet_link(request.static_url('tailbone:static/css/layout.css'))}