Changeset eafe373 in tailbone


Ignore:
Timestamp:
03/09/19 21:22:07 (11 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
20b97a8
Parents:
9f743da
Message:

Refactor template content_title() and prev/next buttons feature

those were intertwined but now are a bit more separate, much better

Location:
tailbone
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • tailbone/templates/base.mako

    r9f743da reafe373  
    8484
    8585        <div class="page">
    86           ${self.content_title()}
     86          % if capture(self.content_title):
     87
     88              % if show_prev_next is not Undefined and show_prev_next:
     89                  <div style="float: right;">
     90                    % if prev_url:
     91                        ${h.link_to("« Older", prev_url, class_='button autodisable')}
     92                    % else:
     93                        ${h.link_to("« Older", '#', class_='button', disabled='disabled')}
     94                    % endif
     95                    % if next_url:
     96                        ${h.link_to("Newer »", next_url, class_='button autodisable')}
     97                    % else:
     98                        ${h.link_to("Newer »", '#', class_='button', disabled='disabled')}
     99                    % endif
     100                  </div>
     101              % endif
     102
     103              <h1>${self.content_title()}</h1>
     104          % endif
    87105        </div>
    88106      </header>
     
    137155
    138156<%def name="content_title()">
    139   <h1>${self.title()}</h1>
     157  ${self.title()}
    140158</%def>
    141159
  • tailbone/templates/master/versions.mako

    r9f743da reafe373  
    1919
    2020<%def name="content_title()">
    21   <h1>History for ${instance_title}</h1>
     21  History for ${instance_title}
    2222</%def>
    2323
  • tailbone/templates/master/view.mako

    r9f743da reafe373  
    2727
    2828<%def name="content_title()">
    29   % if master.supports_prev_next:
    30       <div style="float: right;">
    31         % if prev_instance:
    32             ${h.link_to(u"« Older", url('{}.view'.format(route_prefix), uuid=prev_instance.uuid), class_='button autodisable')}
    33         % else:
    34             ${h.link_to(u"« Older", '#', class_='button', disabled='disabled')}
    35         % endif
    36         % if next_instance:
    37             ${h.link_to(u"Newer »", url('{}.view'.format(route_prefix), uuid=next_instance.uuid), class_='button autodisable')}
    38         % else:
    39             ${h.link_to(u"Newer »", '#', class_='button', disabled='disabled')}
    40         % endif
    41       </div>
    42   % endif
    43   <h1>${instance_title}</h1>
     29  ${instance_title}
    4430</%def>
    4531
  • tailbone/templates/master/view_row.mako

    r9f743da reafe373  
    55
    66<%def name="content_title()">
    7   <h1>${row_title}</h1>
     7  ${row_title}
    88</%def>
    99
  • tailbone/templates/master/view_version.mako

    r9f743da reafe373  
    55
    66## TODO: this was basically copied from Revel diff template..need to abstract
    7 
    8 <%def name="content_title()">
    9   <div style="float: right;">
    10     % if previous_transaction:
    11         ${h.link_to(u"« Older", url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=previous_transaction.id), class_='button')}
    12     % else:
    13         ${h.link_to(u"« Older", '#', class_='button', disabled='disabled')}
    14     % endif
    15     % if next_transaction:
    16         ${h.link_to(u"Newer »", url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=next_transaction.id), class_='button')}
    17     % else:
    18         ${h.link_to(u"Newer »", '#', class_='button', disabled='disabled')}
    19     % endif
    20   </div>
    21   <h1>${self.title()}</h1>
    22 </%def>
    237
    248<div class="form-wrapper">
  • tailbone/templates/themes/bobcat/base.mako

    r9f743da reafe373  
    161161    <section id="content-title" class="hero is-primary">
    162162      <div class="container">
    163         ${self.content_title()}
     163        % if capture(self.content_title):
     164
     165            % if show_prev_next is not Undefined and show_prev_next:
     166                <div style="float: right;">
     167                  % if prev_url:
     168                      ${h.link_to("« Older", prev_url, class_='button autodisable')}
     169                  % else:
     170                      ${h.link_to("« Older", '#', class_='button', disabled='disabled')}
     171                  % endif
     172                  % if next_url:
     173                      ${h.link_to("Newer »", next_url, class_='button autodisable')}
     174                  % else:
     175                      ${h.link_to("Newer »", '#', class_='button', disabled='disabled')}
     176                  % endif
     177                </div>
     178            % endif
     179
     180            <h1 class="title">${self.content_title()}</h1>
     181        % endif
    164182      </div>
    165183    </section>
     
    209227
    210228<%def name="content_title()">
    211   <h1 class="title">${self.title()}</h1>
     229  ${self.title()}
    212230</%def>
    213231
  • tailbone/views/master.py

    r9f743da reafe373  
    10421042        instance = self.get_instance()
    10431043        model_class = self.get_model_class()
     1044        route_prefix = self.get_route_prefix()
    10441045        Transaction = continuum.transaction_class(model_class)
    10451046        transactions = model_transaction_query(self.Session(), instance, model_class,
     
    10591060
    10601061        instance_title = self.get_instance_title(instance)
     1062
     1063        prev_url = next_url = None
     1064        if older:
     1065            prev_url = self.request.route_url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=older.id)
     1066        if newer:
     1067            next_url = self.request.route_url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=newer.id)
     1068
    10611069        return self.render_to_response('view_version', {
    10621070            'instance': instance,
     
    10671075            'changed': localtime(self.rattail_config, transaction.issued_at, from_utc=True),
    10681076            'versions': self.get_relevant_versions(transaction, instance),
     1077            'show_prev_next': True,
     1078            'prev_url': prev_url,
     1079            'next_url': next_url,
    10691080            'previous_transaction': older,
    10701081            'next_transaction': newer,
  • tailbone/views/upgrades.py

    r9f743da reafe373  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2018 Lance Edgar
     5#  Copyright © 2010-2019 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    6969    execute_progress_template = '/upgrade.mako'
    7070    execute_progress_initial_msg = "Upgrading"
    71     supports_prev_next = True
    7271
    7372    labels = {
     
    143142    def template_kwargs_view(self, **kwargs):
    144143        upgrade = kwargs['instance']
     144
     145        kwargs['show_prev_next'] = True
     146        kwargs['prev_url'] = None
     147        kwargs['next_url'] = None
     148
    145149        upgrades = self.Session.query(model.Upgrade)\
    146150                               .filter(model.Upgrade.uuid != upgrade.uuid)
    147         kwargs['prev_instance'] = upgrades.filter(model.Upgrade.created <= upgrade.created)\
    148                                           .order_by(model.Upgrade.created.desc())\
    149                                           .first()
    150         kwargs['next_instance'] = upgrades.filter(model.Upgrade.created >= upgrade.created)\
    151                                           .order_by(model.Upgrade.created)\
    152                                           .first()
     151        older = upgrades.filter(model.Upgrade.created <= upgrade.created)\
     152                        .order_by(model.Upgrade.created.desc())\
     153                        .first()
     154        newer = upgrades.filter(model.Upgrade.created >= upgrade.created)\
     155                        .order_by(model.Upgrade.created)\
     156                        .first()
     157
     158        if older:
     159            kwargs['prev_url'] = self.get_action_url('view', older)
     160        if newer:
     161            kwargs['next_url'] = self.get_action_url('view', newer)
     162
    153163        return kwargs
    154164
Note: See TracChangeset for help on using the changeset viewer.