Only attempt to count versions for versioned models.
This commit is contained in:
parent
75729be79f
commit
5ad5cb569d
|
@ -34,6 +34,7 @@ except ImportError:
|
|||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy_continuum import transaction_class, version_class
|
||||
from sqlalchemy_continuum.utils import is_versioned
|
||||
|
||||
from rattail.db import model
|
||||
from rattail.db.model.continuum import count_versions, model_transaction_query
|
||||
|
@ -169,9 +170,9 @@ class CrudView(View):
|
|||
pass
|
||||
|
||||
def template_kwargs(self, form):
|
||||
if form.creating:
|
||||
return {}
|
||||
if not form.creating and is_versioned(self.mapped_class):
|
||||
return {'version_count': self.count_versions()}
|
||||
return {}
|
||||
|
||||
def count_versions(self):
|
||||
query = self.transaction_query()
|
||||
|
|
Loading…
Reference in a new issue