fix: some fixes for wutta people view
This commit is contained in:
parent
4c3e3aeb6a
commit
29531c83c4
|
@ -24,9 +24,10 @@
|
|||
Core Grid Classes
|
||||
"""
|
||||
|
||||
from urllib.parse import urlencode
|
||||
import warnings
|
||||
import inspect
|
||||
import logging
|
||||
import warnings
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
@ -858,9 +859,13 @@ class Grid(WuttaGrid):
|
|||
settings['page'] = self.page
|
||||
if self.filterable:
|
||||
for filtr in self.iter_filters():
|
||||
settings['filter.{}.active'.format(filtr.key)] = filtr.default_active
|
||||
settings['filter.{}.verb'.format(filtr.key)] = filtr.default_verb
|
||||
settings['filter.{}.value'.format(filtr.key)] = filtr.default_value
|
||||
defaults = self.filter_defaults.get(filtr.key, {})
|
||||
settings[f'filter.{filtr.key}.active'] = defaults.get('active',
|
||||
filtr.default_active)
|
||||
settings[f'filter.{filtr.key}.verb'] = defaults.get('verb',
|
||||
filtr.default_verb)
|
||||
settings[f'filter.{filtr.key}.value'] = defaults.get('value',
|
||||
filtr.default_value)
|
||||
|
||||
# If user has default settings on file, apply those first.
|
||||
if self.user_has_defaults():
|
||||
|
@ -1239,7 +1244,7 @@ class Grid(WuttaGrid):
|
|||
view = None
|
||||
for action in self.actions:
|
||||
if action.key == 'view':
|
||||
return action.click_handler
|
||||
return getattr(action, 'click_handler', None)
|
||||
|
||||
def set_filters_sequence(self, filters, only=False):
|
||||
"""
|
||||
|
@ -1475,10 +1480,22 @@ class Grid(WuttaGrid):
|
|||
|
||||
# leverage configured rendering logic where applicable;
|
||||
# otherwise use "raw" data value as string
|
||||
if self.renderers and name in self.renderers:
|
||||
value = self.renderers[name](rowobj, name)
|
||||
else:
|
||||
value = self.obtain_value(rowobj, name)
|
||||
if self.renderers and name in self.renderers:
|
||||
renderer = self.renderers[name]
|
||||
|
||||
# TODO: legacy renderer callables require 2 args,
|
||||
# but wuttaweb callables require 3 args
|
||||
sig = inspect.signature(renderer)
|
||||
required = [param for param in sig.parameters.values()
|
||||
if param.default == param.empty]
|
||||
|
||||
if len(required) == 2:
|
||||
# TODO: legacy renderer
|
||||
value = renderer(rowobj, name)
|
||||
else: # the future
|
||||
value = renderer(rowobj, name, value)
|
||||
|
||||
if value is None:
|
||||
value = ""
|
||||
|
||||
|
|
|
@ -612,7 +612,9 @@ class MasterView(View):
|
|||
|
||||
# delete action
|
||||
if self.rows_deletable and self.has_perm('delete_row'):
|
||||
actions.append(self.make_action('delete', icon='trash', url=self.row_delete_action_url))
|
||||
actions.append(self.make_action('delete', icon='trash',
|
||||
url=self.row_delete_action_url,
|
||||
link_class='has-text-danger'))
|
||||
defaults['delete_speedbump'] = self.rows_deletable_speedbump
|
||||
|
||||
defaults['actions'] = actions
|
||||
|
@ -3322,7 +3324,7 @@ class MasterView(View):
|
|||
url=self.default_clone_url)
|
||||
|
||||
def make_grid_action_delete(self):
|
||||
kwargs = {}
|
||||
kwargs = {'link_class': 'has-text-danger'}
|
||||
if self.delete_confirm == 'simple':
|
||||
kwargs['click_handler'] = 'deleteObject'
|
||||
return self.make_action('delete', icon='trash', url=self.default_delete_url, **kwargs)
|
||||
|
|
|
@ -32,6 +32,7 @@ from wuttaweb.views import people as wutta
|
|||
from tailbone.views import people as tailbone
|
||||
from tailbone.db import Session
|
||||
from rattail.db.model import Person
|
||||
from tailbone.grids import Grid
|
||||
|
||||
|
||||
class PersonView(wutta.PersonView):
|
||||
|
@ -44,7 +45,6 @@ class PersonView(wutta.PersonView):
|
|||
"""
|
||||
model_class = Person
|
||||
Session = Session
|
||||
sort_defaults = 'display_name'
|
||||
|
||||
labels = {
|
||||
'display_name': "Full Name",
|
||||
|
@ -59,6 +59,11 @@ class PersonView(wutta.PersonView):
|
|||
'merge_requested',
|
||||
]
|
||||
|
||||
filter_defaults = {
|
||||
'display_name': {'active': True, 'verb': 'contains'},
|
||||
}
|
||||
sort_defaults = 'display_name'
|
||||
|
||||
form_fields = [
|
||||
'first_name',
|
||||
'middle_name',
|
||||
|
@ -74,6 +79,11 @@ class PersonView(wutta.PersonView):
|
|||
# CRUD methods
|
||||
##############################
|
||||
|
||||
# TODO: must use older grid for now, to render filters correctly
|
||||
def make_grid(self, **kwargs):
|
||||
""" """
|
||||
return Grid(self.request, **kwargs)
|
||||
|
||||
def configure_grid(self, g):
|
||||
""" """
|
||||
super().configure_grid(g)
|
||||
|
|
Loading…
Reference in a new issue