fix: use local/custom enum for continuum operations

since we can't rely on that existing in rattail proper, due to it not
always having sqlalchemy
This commit is contained in:
Lance Edgar 2024-11-12 19:45:24 -06:00
parent 20b3f87dbe
commit ac439c949b

View file

@ -27,8 +27,6 @@ Tools for displaying data diffs
import sqlalchemy as sa
import sqlalchemy_continuum as continuum
from rattail.enum import CONTINUUM_OPERATION
from pyramid.renderers import render
from webhelpers2.html import HTML
@ -272,11 +270,21 @@ class VersionDiff(Diff):
for field in self.fields:
values[field] = {'before': self.render_old_value(field),
'after': self.render_new_value(field)}
operation = None
if self.version.operation_type == continuum.Operation.INSERT:
operation = 'INSERT'
elif self.version.operation_type == continuum.Operation.UPDATE:
operation = 'UPDATE'
elif self.version.operation_type == continuum.Operation.DELETE:
operation = 'DELETE'
else:
operation = self.version.operation_type
return {
'key': id(self.version),
'model_title': self.title,
'operation': CONTINUUM_OPERATION.get(self.version.operation_type,
self.version.operation_type),
'operation': operation,
'diff_class': self.nature,
'fields': self.fields,
'values': values,