Changeset eb78d79 in tailbone


Ignore:
Timestamp:
01/25/19 19:36:13 (13 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
d183023
Parents:
90e1bae
Message:

Update tempmon UI now that enabled flags are really datetime in DB

Location:
tailbone
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tailbone/forms/types.py

    r90e1bae reb78d79  
    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.
     
    2828
    2929import re
     30import datetime
    3031
    3132import six
     
    6263        # re-try first format, for "better" error message
    6364        return colander.timeparse(cstruct, formats[0])
     65
     66
     67class DateTimeBoolean(colander.Boolean):
     68    """
     69    Schema type which presents the user with a "boolean" whereas the underlying
     70    node is really a datetime (assumed to be "naive" UTC, and allow nulls).
     71    """
     72
     73    def deserialize(self, node, cstruct):
     74        value = super(DateTimeBoolean, self).deserialize(node, cstruct)
     75        if value: # else return None
     76            return datetime.datetime.utcnow()
    6477
    6578
  • tailbone/templates/tempmon/probes/view.mako

    r90e1bae reb78d79  
    66##############################
    77
    8 <ul id="context-menu">
    9   ${self.context_menu_items()}
    10 </ul>
     8<div style="display: flex; justify-content: space-between;">
    119
    12 <div class="form-wrapper">
     10  <div class="form-wrapper">
    1311
    14   <div class="panel" id="probe-main">
    15     <h2>General</h2>
    16     <div class="panel-body">
    17       <div style="clear: none; float: left;">
    18         ${self.render_main_fields(form)}
     12    <div style="display: flex; flex-direction: column;">
     13
     14      <div class="panel" id="probe-main">
     15        <h2>General</h2>
     16        <div class="panel-body">
     17          <div>
     18            ${self.render_main_fields(form)}
     19          </div>
     20        </div>
    1921      </div>
    20 ##       % if image_url:
    21 ##           ${h.image(image_url, "Probe Image", id='probe-image', width=150, height=150)}
    22 ##       % endif
     22
     23      <div style="display: flex;">
     24        <div class="panel-wrapper">
     25          ${self.left_column()}
     26        </div>
     27        <div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
     28          ${self.right_column()}
     29        </div>
     30      </div>
     31
    2332    </div>
    2433  </div>
    2534
    26   <div class="panel-wrapper">
    27     ${self.left_column()}
    28   </div>
    29 
    30   <div class="panel-wrapper">
    31     ${self.right_column()}
    32   </div>
     35  <ul id="context-menu">
     36    ${self.context_menu_items()}
     37  </ul>
    3338
    3439</div>
  • tailbone/views/tempmon/clients.py

    r90e1bae reb78d79  
    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.
     
    3535from webhelpers2.html import HTML, tags
    3636
     37from tailbone import forms
    3738from tailbone.views.tempmon import MasterView
    3839
     
    102103        g.set_enum('disk_type', self.enum.TEMPMON_DISK_TYPE)
    103104
     105        # enabled
     106        g.set_type('enabled', 'boolean')
     107
    104108        # archived
    105109        g.filters['archived'].default_active = True
     
    135139
    136140        # enabled
     141        if self.creating or self.editing:
     142            f.set_node('enabled', forms.types.DateTimeBoolean())
    137143        f.set_helptext('enabled', tempmon.Client.enabled.__doc__)
    138144
     
    145151        # archived
    146152        f.set_helptext('archived', tempmon.Client.archived.__doc__)
     153
     154    def objectify(self, form, data=None):
     155
     156        # this is a hack to prevent updates to the 'enabled' timestamp, when
     157        # simple edits are being done to the client.  i.e. we do want to set
     158        # the timestamp when it was previously null, but not otherwise.
     159        if self.editing:
     160            data = dict(data or form.validated)
     161            if data['enabled'] and form.model_instance.enabled:
     162                data['enabled'] = form.model_instance.enabled
     163
     164        return super(TempmonClientView, self).objectify(form, data=data)
    147165
    148166    def unique_config_key(self, node, value):
  • tailbone/views/tempmon/probes.py

    r90e1bae reb78d79  
    3838from webhelpers2.html import tags
    3939
    40 from tailbone import grids
     40from tailbone import forms, grids
    4141from tailbone.views.tempmon import MasterView
    4242
     
    169169            f.remove_fields('status')
    170170
     171        # enabled
     172        if self.creating or self.editing:
     173            f.set_node('enabled', forms.types.DateTimeBoolean())
     174        f.set_helptext('enabled', tempmon.Probe.enabled.__doc__)
     175
     176    def objectify(self, form, data=None):
     177
     178        # this is a hack to prevent updates to the 'enabled' timestamp, when
     179        # simple edits are being done to the probe.  i.e. we do want to set the
     180        # timestamp when it was previously null, but not otherwise.
     181        if self.editing:
     182            data = dict(data or form.validated)
     183            if data['enabled'] and form.model_instance.enabled:
     184                data['enabled'] = form.model_instance.enabled
     185
     186        return super(TempmonProbeView, self).objectify(form, data=data)
     187
    171188    def unique_config_key(self, node, value):
    172189        query = self.Session.query(tempmon.Probe)\
Note: See TracChangeset for help on using the changeset viewer.