Remove unused code for webhelpers2_grid

This commit is contained in:
Lance Edgar 2024-04-19 20:15:44 -05:00
parent 5cb643a32a
commit 36b9e00dc9
2 changed files with 0 additions and 70 deletions

View file

@ -40,12 +40,6 @@ classifiers =
[options]
install_requires =
# TODO: apparently they jumped from 0.1 to 0.9 and that broke us...
# (0.1 was released on 2014-09-14 and then 0.9 came out on 2018-09-27)
# (i've cached 0.1 at pypi.rattailproject.org just in case it disappears)
# (still, probably a better idea is to refactor so we can use 0.9)
webhelpers2_grid==0.1
# TODO: remove once their bug is fixed? idk what this is about yet...
deform<2.0.15

View file

@ -34,7 +34,6 @@ from sqlalchemy import orm
from rattail.db.types import GPCType
from rattail.util import prettify, pretty_boolean, pretty_quantity
import webhelpers2_grid
from pyramid.renderers import render
from webhelpers2.html import HTML, tags
from paginate_sqlalchemy import SqlalchemyOrmPage
@ -1721,69 +1720,6 @@ class Grid(object):
return False
class CustomWebhelpersGrid(webhelpers2_grid.Grid):
"""
Implement column sorting links etc. for webhelpers2_grid
"""
def __init__(self, itemlist, columns, **kwargs):
self.renderers = kwargs.pop('renderers', {})
self.linked_columns = kwargs.pop('linked_columns', [])
self.extra_record_class = kwargs.pop('extra_record_class', None)
super().__init__(itemlist, columns, **kwargs)
def generate_header_link(self, column_number, column, label_text):
# display column header as simple no-op link; client-side JS takes care
# of the rest for us
label_text = tags.link_to(label_text, '#', data_sortkey=column)
# Is the current column the one we're ordering on?
if (column == self.order_column):
return self.default_header_ordered_column_format(column_number,
column,
label_text)
else:
return self.default_header_column_format(column_number, column,
label_text)
def default_record_format(self, i, record, columns):
kwargs = {
'class_': self.get_record_class(i, record, columns),
}
if hasattr(record, 'uuid'):
kwargs['data_uuid'] = record.uuid
return HTML.tag('tr', columns, **kwargs)
def get_record_class(self, i, record, columns):
if i % 2 == 0:
cls = 'even r{}'.format(i)
else:
cls = 'odd r{}'.format(i)
if self.extra_record_class:
extra = self.extra_record_class(record, i)
if extra:
cls = '{} {}'.format(cls, extra)
return cls
def get_column_value(self, column_number, i, record, column_name):
if self.renderers and column_name in self.renderers:
return self.renderers[column_name](record, column_name)
try:
return record[column_name]
except TypeError:
return getattr(record, column_name)
def default_column_format(self, column_number, i, record, column_name):
value = self.get_column_value(column_number, i, record, column_name)
if self.linked_columns and column_name in self.linked_columns and (
value is not None and value != ''):
url = self.url_generator(record, i)
value = tags.link_to(value, url)
class_name = 'c{} {}'.format(column_number, column_name)
return HTML.tag('td', value, class_=class_name)
class GridAction(object):
"""
Represents an action available to a grid. This is used to construct the