refactoring
This commit is contained in:
parent
0c5897a06c
commit
1400d292ce
|
@ -28,7 +28,7 @@ from teal.resource import url_for_resource
|
||||||
from ereuse_devicehub.db import db
|
from ereuse_devicehub.db import db
|
||||||
from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \
|
from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \
|
||||||
DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState
|
DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState
|
||||||
from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, update_timestamp
|
from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, listener_reset_field_updated_in_actual_time
|
||||||
from ereuse_devicehub.resources.user.models import User
|
from ereuse_devicehub.resources.user.models import User
|
||||||
|
|
||||||
|
|
||||||
|
@ -883,57 +883,4 @@ class Manufacturer(db.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
listener_reset_field_updated_in_actual_time(Device)
|
||||||
update_timestamp(Computer)
|
|
||||||
update_timestamp(Desktop)
|
|
||||||
update_timestamp(Laptop)
|
|
||||||
update_timestamp(Server)
|
|
||||||
update_timestamp(Monitor)
|
|
||||||
update_timestamp(ComputerMonitor)
|
|
||||||
update_timestamp(TelevisionSet)
|
|
||||||
update_timestamp(Projector)
|
|
||||||
update_timestamp(Mobile)
|
|
||||||
update_timestamp(Smartphone)
|
|
||||||
update_timestamp(Tablet)
|
|
||||||
update_timestamp(Cellphone)
|
|
||||||
update_timestamp(Component)
|
|
||||||
update_timestamp(GraphicCard)
|
|
||||||
update_timestamp(DataStorage)
|
|
||||||
update_timestamp(HardDrive)
|
|
||||||
update_timestamp(SolidStateDrive)
|
|
||||||
update_timestamp(Motherboard)
|
|
||||||
update_timestamp(NetworkAdapter)
|
|
||||||
update_timestamp(Processor)
|
|
||||||
update_timestamp(RamModule)
|
|
||||||
update_timestamp(SoundCard)
|
|
||||||
update_timestamp(Display)
|
|
||||||
update_timestamp(Battery)
|
|
||||||
update_timestamp(Camera)
|
|
||||||
update_timestamp(ComputerAccessory)
|
|
||||||
update_timestamp(SAI)
|
|
||||||
update_timestamp(Keyboard)
|
|
||||||
update_timestamp(Mouse)
|
|
||||||
update_timestamp(MemoryCardReader)
|
|
||||||
update_timestamp(Networking)
|
|
||||||
update_timestamp(Router)
|
|
||||||
update_timestamp(Switch)
|
|
||||||
update_timestamp(Hub)
|
|
||||||
update_timestamp(WirelessAccessPoint)
|
|
||||||
update_timestamp(Printer)
|
|
||||||
update_timestamp(LabelPrinter)
|
|
||||||
update_timestamp(Sound)
|
|
||||||
update_timestamp(Microphone)
|
|
||||||
update_timestamp(Video)
|
|
||||||
update_timestamp(VideoScaler)
|
|
||||||
update_timestamp(Videoconference)
|
|
||||||
update_timestamp(Cooking)
|
|
||||||
update_timestamp(Mixer)
|
|
||||||
update_timestamp(DIYAndGardening)
|
|
||||||
update_timestamp(Drill)
|
|
||||||
update_timestamp(PackOfScrewdrivers)
|
|
||||||
update_timestamp(Home)
|
|
||||||
update_timestamp(Dehumidifier)
|
|
||||||
update_timestamp(Stairs)
|
|
||||||
update_timestamp(Recreation)
|
|
||||||
update_timestamp(Bike)
|
|
||||||
update_timestamp(Racket)
|
|
||||||
|
|
|
@ -37,10 +37,10 @@ class Thing(db.Model):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
def on_update_time(mapper, connection, thing_obj):
|
def update_object_timestamp(mapper, connection, thing_obj):
|
||||||
""" This function update the stamptime of field updated """
|
""" This function update the stamptime of field updated """
|
||||||
thing_obj.updated = datetime.now()
|
thing_obj.updated = datetime.now(timezone.utc)
|
||||||
|
|
||||||
def update_timestamp(thing_obj):
|
def listener_reset_field_updated_in_actual_time(thing_obj):
|
||||||
""" This function launch a event than listen like a signal when some object is saved """
|
""" This function launch a event than listen like a signal when some object is saved """
|
||||||
event.listen(thing_obj, 'before_update', on_update_time)
|
event.listen(thing_obj, 'before_update', update_object_timestamp, propagate=True)
|
||||||
|
|
Reference in New Issue