diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index 1f04b07e..161bfa25 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -24,12 +24,9 @@ Forms Core """ -from __future__ import unicode_literals, absolute_import - import json import logging -import six import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.ext.associationproxy import AssociationProxy, ASSOCIATION_PROXY @@ -338,7 +335,7 @@ class Form(object): model_instance=None, model_class=None, appstruct=UNSPECIFIED, nodes={}, enums={}, labels={}, assume_local_times=False, renderers=None, renderer_kwargs={}, hidden={}, widgets={}, defaults={}, validators={}, required={}, helptext={}, focus_spec=None, - action_url=None, cancel_url=None, use_buefy=True, component='tailbone-form', + action_url=None, cancel_url=None, component='tailbone-form', vuejs_field_converters={}, # TODO: ugh this is getting out hand! can_edit_help=False, edit_help_url=None, route_prefix=None, @@ -377,7 +374,6 @@ class Form(object): self.focus_spec = focus_spec self.action_url = action_url self.cancel_url = cancel_url - self.use_buefy = use_buefy self.component = component self.vuejs_field_converters = vuejs_field_converters or {} self.can_edit_help = can_edit_help @@ -758,10 +754,7 @@ class Form(object): def render(self, template=None, **kwargs): if not template: - if self.readonly and not self.use_buefy: - template = '/forms/form_readonly.mako' - else: - template = '/forms/form.mako' + template = '/forms/form.mako' context = kwargs context['form'] = self return render(template, context) @@ -806,10 +799,7 @@ class Form(object): def render_deform(self, dform=None, template=None, **kwargs): if not template: - if self.use_buefy: - template = '/forms/deform_buefy.mako' - else: - template = '/forms/deform.mako' + template = '/forms/deform_buefy.mako' if dform is None: dform = self.make_deform_form() @@ -829,11 +819,8 @@ class Form(object): context.setdefault('form_kwargs', {}) # TODO: deprecate / remove the latter option here if self.auto_disable_save or self.auto_disable: - if self.use_buefy: - context['form_kwargs'].setdefault('ref', self.component_studly) - context['form_kwargs']['@submit'] = 'submit{}'.format(self.component_studly) - else: - context['form_kwargs']['class_'] = 'autodisable' + context['form_kwargs'].setdefault('ref', self.component_studly) + context['form_kwargs']['@submit'] = 'submit{}'.format(self.component_studly) if self.focus_spec: context['form_kwargs']['data-focus'] = self.focus_spec context['request'] = self.request @@ -975,8 +962,7 @@ class Form(object): if self.readonly or fieldname in self.readonly_fields: html = self.render_field_value(fieldname) or HTML.tag('span') elif field: - html = field.serialize(use_buefy=True, - **self.get_renderer_kwargs(fieldname)) + html = field.serialize(**self.get_renderer_kwargs(fieldname)) html = HTML.literal(html) # may need a complex label @@ -1064,7 +1050,7 @@ class Form(object): value = self.obtain_value(record, field_name) if value is None: return "" - return six.text_type(value) + return str(value) def render_datetime(self, record, field_name): value = self.obtain_value(record, field_name) @@ -1099,7 +1085,7 @@ class Form(object): return "(${:0,.2f})".format(0 - value) return "${:0,.2f}".format(value) except ValueError: - return six.text_type(value) + return str(value) def render_quantity(self, obj, field): value = self.obtain_value(obj, field) @@ -1124,8 +1110,8 @@ class Form(object): return "" enum = self.enums.get(field_name) if enum and value in enum: - return six.text_type(enum[value]) - return six.text_type(value) + return str(enum[value]) + return str(value) def render_codeblock(self, record, field_name): value = self.obtain_value(record, field_name) @@ -1193,8 +1179,8 @@ class Form(object): controls[i][1] = 'true' elif value is False: controls[i][1] = 'false' - elif not isinstance(value, six.string_types): - controls[i][1] = six.text_type(value) + elif not isinstance(value, str): + controls[i][1] = str(value) dform = self.make_deform_form() try: diff --git a/tailbone/static/css/jquery.tagit.css b/tailbone/static/css/jquery.tagit.css deleted file mode 100644 index f18650d9..00000000 --- a/tailbone/static/css/jquery.tagit.css +++ /dev/null @@ -1,69 +0,0 @@ -ul.tagit { - padding: 1px 5px; - overflow: auto; - margin-left: inherit; /* usually we don't want the regular ul margins. */ - margin-right: inherit; -} -ul.tagit li { - display: block; - float: left; - margin: 2px 5px 2px 0; -} -ul.tagit li.tagit-choice { - position: relative; - line-height: inherit; -} -input.tagit-hidden-field { - display: none; -} -ul.tagit li.tagit-choice-read-only { - padding: .2em .5em .2em .5em; -} - -ul.tagit li.tagit-choice-editable { - padding: .2em 18px .2em .5em; -} - -ul.tagit li.tagit-new { - padding: .25em 4px .25em 0; -} - -ul.tagit li.tagit-choice a.tagit-label { - cursor: pointer; - text-decoration: none; -} -ul.tagit li.tagit-choice .tagit-close { - cursor: pointer; - position: absolute; - right: .1em; - top: 50%; - margin-top: -8px; - line-height: 17px; -} - -/* used for some custom themes that don't need image icons */ -ul.tagit li.tagit-choice .tagit-close .text-icon { - display: none; -} - -ul.tagit li.tagit-choice input { - display: block; - float: left; - margin: 2px 5px 2px 0; -} -ul.tagit input[type="text"] { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; - - -moz-box-shadow: none; - -webkit-box-shadow: none; - box-shadow: none; - - border: none; - margin: 0; - padding: 0; - width: inherit; - background-color: inherit; - outline: none; -} diff --git a/tailbone/static/css/login.css b/tailbone/static/css/login.css deleted file mode 100644 index 448f9f70..00000000 --- a/tailbone/static/css/login.css +++ /dev/null @@ -1,48 +0,0 @@ - -/****************************** - * login.css - ******************************/ - -.logo img, -#logo { - display: block; - margin: 40px auto; - max-height: 350px; - max-width: 800px; -} - -div.form { - margin: auto; - float: none; - text-align: center; -} - -div.field-wrapper { - margin: 10px auto; - width: 300px; -} - -div.field-wrapper label { - text-align: right; - width: auto; -} - -div.field-wrapper div.field input[type="text"], -div.field-wrapper div.field input[type="password"] { - margin-left: 1em; - width: 150px; -} - -div.buttons { - display: block; -} - -div.buttons input { - margin: auto 5px; -} - -/* this is for "login as chuck" tip in demo mode */ -.tips { - margin-top: 2em; - text-align: center; -} diff --git a/tailbone/static/js/lib/tag-it.min.js b/tailbone/static/js/lib/tag-it.min.js deleted file mode 100644 index fd6140c8..00000000 --- a/tailbone/static/js/lib/tag-it.min.js +++ /dev/null @@ -1,17 +0,0 @@ -(function(b){b.widget("ui.tagit",{options:{allowDuplicates:!1,caseSensitive:!0,fieldName:"tags",placeholderText:null,readOnly:!1,removeConfirmation:!1,tagLimit:null,availableTags:[],autocomplete:{},showAutocompleteOnFocus:!1,allowSpaces:!1,singleField:!1,singleFieldDelimiter:",",singleFieldNode:null,animate:!0,tabIndex:null,beforeTagAdded:null,afterTagAdded:null,beforeTagRemoved:null,afterTagRemoved:null,onTagClicked:null,onTagLimitExceeded:null,onTagAdded:null,onTagRemoved:null,tagSource:null},_create:function(){var a= -this;this.element.is("input")?(this.tagList=b("").insertAfter(this.element),this.options.singleField=!0,this.options.singleFieldNode=this.element,this.element.addClass("tagit-hidden-field")):this.tagList=this.element.find("ul, ol").andSelf().last();this.tagInput=b('').addClass("ui-widget-content");this.options.readOnly&&this.tagInput.attr("disabled","disabled");this.options.tabIndex&&this.tagInput.attr("tabindex",this.options.tabIndex);this.options.placeholderText&&this.tagInput.attr("placeholder", -this.options.placeholderText);this.options.autocomplete.source||(this.options.autocomplete.source=function(a,e){var d=a.term.toLowerCase(),c=b.grep(this.options.availableTags,function(a){return 0===a.toLowerCase().indexOf(d)});this.options.allowDuplicates||(c=this._subtractArray(c,this.assignedTags()));e(c)});this.options.showAutocompleteOnFocus&&(this.tagInput.focus(function(b,d){a._showAutocomplete()}),"undefined"===typeof this.options.autocomplete.minLength&&(this.options.autocomplete.minLength= -0));b.isFunction(this.options.autocomplete.source)&&(this.options.autocomplete.source=b.proxy(this.options.autocomplete.source,this));b.isFunction(this.options.tagSource)&&(this.options.tagSource=b.proxy(this.options.tagSource,this));this.tagList.addClass("tagit").addClass("ui-widget ui-widget-content ui-corner-all").append(b('
  • ').append(this.tagInput)).click(function(d){var c=b(d.target);c.hasClass("tagit-label")?(c=c.closest(".tagit-choice"),c.hasClass("removed")||a._trigger("onTagClicked", -d,{tag:c,tagLabel:a.tagLabel(c)})):a.tagInput.focus()});var c=!1;if(this.options.singleField)if(this.options.singleFieldNode){var d=b(this.options.singleFieldNode),f=d.val().split(this.options.singleFieldDelimiter);d.val("");b.each(f,function(b,d){a.createTag(d,null,!0);c=!0})}else this.options.singleFieldNode=b(''),this.tagList.after(this.options.singleFieldNode);c||this.tagList.children("li").each(function(){b(this).hasClass("tagit-new")|| -(a.createTag(b(this).text(),b(this).attr("class"),!0),b(this).remove())});this.tagInput.keydown(function(c){if(c.which==b.ui.keyCode.BACKSPACE&&""===a.tagInput.val()){var d=a._lastTag();!a.options.removeConfirmation||d.hasClass("remove")?a.removeTag(d):a.options.removeConfirmation&&d.addClass("remove ui-state-highlight")}else a.options.removeConfirmation&&a._lastTag().removeClass("remove ui-state-highlight");if(c.which===b.ui.keyCode.COMMA&&!1===c.shiftKey||c.which===b.ui.keyCode.ENTER||c.which== -b.ui.keyCode.TAB&&""!==a.tagInput.val()||c.which==b.ui.keyCode.SPACE&&!0!==a.options.allowSpaces&&('"'!=b.trim(a.tagInput.val()).replace(/^s*/,"").charAt(0)||'"'==b.trim(a.tagInput.val()).charAt(0)&&'"'==b.trim(a.tagInput.val()).charAt(b.trim(a.tagInput.val()).length-1)&&0!==b.trim(a.tagInput.val()).length-1))c.which===b.ui.keyCode.ENTER&&""===a.tagInput.val()||c.preventDefault(),a.options.autocomplete.autoFocus&&a.tagInput.data("autocomplete-open")||(a.tagInput.autocomplete("close"),a.createTag(a._cleanedInput()))}).blur(function(b){a.tagInput.data("autocomplete-open")|| -a.createTag(a._cleanedInput())});if(this.options.availableTags||this.options.tagSource||this.options.autocomplete.source)d={select:function(b,c){a.createTag(c.item.value);return!1}},b.extend(d,this.options.autocomplete),d.source=this.options.tagSource||d.source,this.tagInput.autocomplete(d).bind("autocompleteopen.tagit",function(b,c){a.tagInput.data("autocomplete-open",!0)}).bind("autocompleteclose.tagit",function(b,c){a.tagInput.data("autocomplete-open",!1)}),this.tagInput.autocomplete("widget").addClass("tagit-autocomplete")}, -destroy:function(){b.Widget.prototype.destroy.call(this);this.element.unbind(".tagit");this.tagList.unbind(".tagit");this.tagInput.removeData("autocomplete-open");this.tagList.removeClass("tagit ui-widget ui-widget-content ui-corner-all tagit-hidden-field");this.element.is("input")?(this.element.removeClass("tagit-hidden-field"),this.tagList.remove()):(this.element.children("li").each(function(){b(this).hasClass("tagit-new")?b(this).remove():(b(this).removeClass("tagit-choice ui-widget-content ui-state-default ui-state-highlight ui-corner-all remove tagit-choice-editable tagit-choice-read-only"), -b(this).text(b(this).children(".tagit-label").text()))}),this.singleFieldNode&&this.singleFieldNode.remove());return this},_cleanedInput:function(){return b.trim(this.tagInput.val().replace(/^"(.*)"$/,"$1"))},_lastTag:function(){return this.tagList.find(".tagit-choice:last:not(.removed)")},_tags:function(){return this.tagList.find(".tagit-choice:not(.removed)")},assignedTags:function(){var a=this,c=[];this.options.singleField?(c=b(this.options.singleFieldNode).val().split(this.options.singleFieldDelimiter), -""===c[0]&&(c=[])):this._tags().each(function(){c.push(a.tagLabel(this))});return c},_updateSingleTagsField:function(a){b(this.options.singleFieldNode).val(a.join(this.options.singleFieldDelimiter)).trigger("change")},_subtractArray:function(a,c){for(var d=[],f=0;f=this.options.tagLimit)return this._trigger("onTagLimitExceeded",null,{duringInitialization:d}),!1;var g=b(this.options.onTagClicked?'':'').text(a),e=b("
  • ").addClass("tagit-choice ui-widget-content ui-state-default ui-corner-all").addClass(c).append(g); -this.options.readOnly?e.addClass("tagit-choice-read-only"):(e.addClass("tagit-choice-editable"),c=b("").addClass("ui-icon ui-icon-close"),c=b('\u00d7').addClass("tagit-close").append(c).click(function(a){f.removeTag(e)}),e.append(c));this.options.singleField||(g=g.html(),e.append(''));!1!==this._trigger("beforeTagAdded",null,{tag:e,tagLabel:this.tagLabel(e), -duringInitialization:d})&&(this.options.singleField&&(g=this.assignedTags(),g.push(a),this._updateSingleTagsField(g)),this._trigger("onTagAdded",null,e),this.tagInput.val(""),this.tagInput.parent().before(e),this._trigger("afterTagAdded",null,{tag:e,tagLabel:this.tagLabel(e),duringInitialization:d}),this.options.showAutocompleteOnFocus&&!d&&setTimeout(function(){f._showAutocomplete()},0))},removeTag:function(a,c){c="undefined"===typeof c?this.options.animate:c;a=b(a);this._trigger("onTagRemoved", -null,a);if(!1!==this._trigger("beforeTagRemoved",null,{tag:a,tagLabel:this.tagLabel(a)})){if(this.options.singleField){var d=this.assignedTags(),f=this.tagLabel(a),d=b.grep(d,function(a){return a!=f});this._updateSingleTagsField(d)}if(c){a.addClass("removed");var d=this._effectExists("blind")?["blind",{direction:"horizontal"},"fast"]:["fast"],g=this;d.push(function(){a.remove();g._trigger("afterTagRemoved",null,{tag:a,tagLabel:g.tagLabel(a)})});a.fadeOut("fast").hide.apply(a,d).dequeue()}else a.remove(), -this._trigger("afterTagRemoved",null,{tag:a,tagLabel:this.tagLabel(a)})}},removeTagByLabel:function(a,b){var d=this._findTagByLabel(a);if(!d)throw"No such tag exists with the name '"+a+"'";this.removeTag(d,b)},removeAll:function(){var a=this;this._tags().each(function(b,d){a.removeTag(d,!1)})}})})(jQuery); diff --git a/tailbone/static/js/login.js b/tailbone/static/js/login.js deleted file mode 100644 index f2a072b8..00000000 --- a/tailbone/static/js/login.js +++ /dev/null @@ -1,32 +0,0 @@ - -$(function() { - - $('input[name="username"]').keydown(function(event) { - if (event.which == 13) { - $('input[name="password"]').focus().select(); - return false; - } - return true; - }); - - $('form').submit(function() { - if (! $('input[name="username"]').val()) { - with ($('input[name="username"]').get(0)) { - select(); - focus(); - } - return false; - } - if (! $('input[name="password"]').val()) { - with ($('input[name="password"]').get(0)) { - select(); - focus(); - } - return false; - } - return true; - }); - - $('input[name="username"]').focus(); - -}); diff --git a/tailbone/static/js/tailbone.appsettings.js b/tailbone/static/js/tailbone.appsettings.js deleted file mode 100644 index ae378931..00000000 --- a/tailbone/static/js/tailbone.appsettings.js +++ /dev/null @@ -1,29 +0,0 @@ - -/************************************************************ - * - * tailbone.appsettings.js - * - * Logic for App Settings page. - * - ************************************************************/ - - -function show_group(group) { - if (group == "(All)") { - $('.panel').show(); - } else { - $('.panel').hide(); - $('.panel[data-groupname="' + group + '"]').show(); - } -} - - -$(function() { - - $('#settings-group').on('selectmenuchange', function(event, ui) { - show_group(ui.item.value); - }); - - show_group($('#settings-group').val()); - -}); diff --git a/tailbone/static/js/tailbone.batch.js b/tailbone/static/js/tailbone.batch.js deleted file mode 100644 index 2844c0b4..00000000 --- a/tailbone/static/js/tailbone.batch.js +++ /dev/null @@ -1,41 +0,0 @@ - -/************************************************************ - * - * tailbone.batch.js - * - * Common logic for view/edit batch pages - * - ************************************************************/ - - -$(function() { - - $('#execute-batch').click(function() { - if (has_execution_options) { - $('#execution-options-dialog').dialog({ - title: "Execution Options", - width: 600, - modal: true, - buttons: [ - { - text: "Execute", - click: function(event) { - dialog_button(event).button('option', 'label', "Executing, please wait...").button('disable'); - $('form[name="batch-execution"]').submit(); - } - }, - { - text: "Cancel", - click: function() { - $(this).dialog('close'); - } - } - ] - }); - } else { - $(this).button('option', 'label', "Executing, please wait...").button('disable'); - $('form[name="batch-execution"]').submit(); - } - }); - -}); diff --git a/tailbone/subscribers.py b/tailbone/subscribers.py index 7ffd92bc..229296ab 100644 --- a/tailbone/subscribers.py +++ b/tailbone/subscribers.py @@ -24,8 +24,6 @@ Event Subscribers """ -from __future__ import unicode_literals, absolute_import - import six import json import datetime @@ -42,7 +40,7 @@ from tailbone import helpers from tailbone.db import Session from tailbone.config import csrf_header_name, should_expose_websockets from tailbone.menus import make_simple_menus -from tailbone.util import should_use_buefy, get_global_search_options +from tailbone.util import get_global_search_options def new_request(event): @@ -156,23 +154,20 @@ def before_render(event): renderer_globals['background_color'] = request.rattail_config.get( 'tailbone', 'background_color') - # buefy themes get some extra treatment - if should_use_buefy(request): + # TODO: remove this hack once nothing references it + renderer_globals['buefy_0_8'] = False - # TODO: remove this hack once nothing references it - renderer_globals['buefy_0_8'] = False + # maybe set custom stylesheet + css = None + if request.user: + css = request.rattail_config.get('tailbone.{}'.format(request.user.uuid), + 'buefy_css') + if not css: + css = request.rattail_config.get('tailbone', 'theme.falafel.buefy_css') + renderer_globals['buefy_css'] = css - # maybe set custom stylesheet - css = None - if request.user: - css = request.rattail_config.get('tailbone.{}'.format(request.user.uuid), - 'buefy_css') - if not css: - css = request.rattail_config.get('tailbone', 'theme.falafel.buefy_css') - renderer_globals['buefy_css'] = css - - # add global search data for quick access - renderer_globals['global_search_data'] = get_global_search_options(request) + # add global search data for quick access + renderer_globals['global_search_data'] = get_global_search_options(request) # here we globally declare widths for grid filter pseudo-columns widths = request.rattail_config.get('tailbone', 'grids.filters.column_widths') diff --git a/tailbone/templates/appsettings.mako b/tailbone/templates/appsettings.mako index a80dafc2..46f4a7e3 100644 --- a/tailbone/templates/appsettings.mako +++ b/tailbone/templates/appsettings.mako @@ -5,34 +5,6 @@ <%def name="content_title()"> -<%def name="extra_javascript()"> - ${parent.extra_javascript()} - % if not use_buefy: - ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.appsettings.js') + '?ver={}'.format(tailbone.__version__))} - % endif - - -<%def name="extra_styles()"> - ${parent.extra_styles()} - % if not use_buefy: - - % endif - - <%def name="context_menu_items()"> % if request.has_perm('settings.list'):
  • ${h.link_to("View Raw Settings", url('settings'))}
  • @@ -223,76 +195,4 @@ -% if use_buefy: - ${parent.body()} - -% else: -## legacy / not buefy -
    - ${h.form(form.action_url, id=dform.formid, method='post', class_='autodisable')} - ${h.csrf_token(request)} - - % if dform.error: -
    -
    - - Please see errors below. -
    -
    - - ${dform.error} -
    -
    - % endif - -
    -
    - -
    - ${h.select('settings-group', current_group, group_options, **{'auto-enhance': 'true'})} -
    -
    -
    - - % for group in groups: -
    -

    ${group}

    -
    - - % for setting in settings: - % if setting.group == group: - <% field = dform[setting.node_name] %> - -
    - % if field.error: -
    - % for msg in field.error.messages(): - ${msg} - % endfor -
    - % endif -
    - -
    - ${field.serialize()|n} -
    -
    - % if form.has_helptext(field.name): - ${form.render_helptext(field.name)} - % endif -
    - % endif - % endfor - -
    -
    - % endfor - -
    - ${h.submit('save', getattr(form, 'submit_label', getattr(form, 'save_label', "Submit")), class_='button is-primary')} - ${h.link_to("Cancel", form.cancel_url, class_='cancel button{}'.format(' autodisable' if form.auto_disable_cancel else ''))} -
    - - ${h.end_form()} -
    -% endif +${parent.body()} diff --git a/tailbone/templates/batch/importer/view_row.mako b/tailbone/templates/batch/importer/view_row.mako index 24eb6456..9e08cf43 100644 --- a/tailbone/templates/batch/importer/view_row.mako +++ b/tailbone/templates/batch/importer/view_row.mako @@ -76,12 +76,5 @@ -<%def name="render_form()"> - ${parent.render_form()} - % if not use_buefy: - ${self.field_diff_table()} - % endif - - ${parent.body()} diff --git a/tailbone/templates/batch/index.mako b/tailbone/templates/batch/index.mako index 89358567..3ea76641 100644 --- a/tailbone/templates/batch/index.mako +++ b/tailbone/templates/batch/index.mako @@ -1,150 +1,66 @@ ## -*- coding: utf-8; -*- <%inherit file="/master/index.mako" /> -<%def name="extra_javascript()"> - ${parent.extra_javascript()} - % if not use_buefy: - % if master.results_executable and master.has_perm('execute_multiple'): - - % endif - % endif - - <%def name="grid_tools()"> ${parent.grid_tools()} ## Refresh Results % if master.results_refreshable and master.has_perm('refresh'): - % if use_buefy: - - {{ refreshResultsButtonText }} - - ${h.form(url('{}.refresh_results'.format(route_prefix)), ref='refreshResultsForm')} - ${h.csrf_token(request)} - ${h.end_form()} - % else: - - % endif + + {{ refreshResultsButtonText }} + + ${h.form(url('{}.refresh_results'.format(route_prefix)), ref='refreshResultsForm')} + ${h.csrf_token(request)} + ${h.end_form()} % endif ## Execute Results % if master.results_executable and master.has_perm('execute_multiple'): - % if use_buefy: - - Execute Results - + + Execute Results + - -