Replace ethereum_address for User with id
This commit is contained in:
parent
e78d62602b
commit
bd2d72ad69
|
@ -49,7 +49,7 @@ class Proof(Thing):
|
||||||
db.ForeignKey(Device.id),
|
db.ForeignKey(Device.id),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
device = db.relationship(Device,
|
device = db.relationship(Device,
|
||||||
backref=db.backref('devices', uselist=True, lazy=True),
|
backref=db.backref('proofs_device', uselist=True, lazy=True),
|
||||||
lazy=True,
|
lazy=True,
|
||||||
primaryjoin=Device.id == device_id)
|
primaryjoin=Device.id == device_id)
|
||||||
|
|
||||||
|
@ -85,28 +85,28 @@ class Proof(Thing):
|
||||||
|
|
||||||
|
|
||||||
class ProofTransfer(JoinedTableMixin, Proof):
|
class ProofTransfer(JoinedTableMixin, Proof):
|
||||||
supplier_id = db.Column(CIText(),
|
supplier_id = db.Column(UUID(as_uuid=True),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.id),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=lambda: g.user.ethereum_address)
|
default=lambda: g.user.id)
|
||||||
supplier = db.relationship(User, primaryjoin=lambda: ProofTransfer.supplier_id == User.ethereum_address)
|
supplier = db.relationship(User, primaryjoin=lambda: ProofTransfer.supplier_id == User.id)
|
||||||
receiver_id = db.Column(CIText(),
|
receiver_id = db.Column(UUID(as_uuid=True),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.id),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
receiver = db.relationship(User, primaryjoin=lambda: ProofTransfer.receiver_id == User.ethereum_address)
|
receiver = db.relationship(User, primaryjoin=lambda: ProofTransfer.receiver_id == User.id)
|
||||||
deposit = Column(db.Integer, default=0)
|
deposit = Column(db.Integer, default=0)
|
||||||
|
|
||||||
|
|
||||||
class ProofDataWipe(JoinedTableMixin, Proof):
|
class ProofDataWipe(JoinedTableMixin, Proof):
|
||||||
erasure_type = Column(CIText(), default='', nullable=False)
|
# erasure_type = Column(CIText(), default='', nullable=False)
|
||||||
date = Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
date = Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
||||||
result = Column(db.Boolean, default=False, nullable=False)
|
result = Column(db.Boolean, default=False, nullable=False)
|
||||||
result.comment = """Identifies proof datawipe as a result."""
|
result.comment = """Identifies proof datawipe as a result."""
|
||||||
proof_author_id = Column(CIText(),
|
proof_author_id = Column(UUID(as_uuid=True),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.id),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=lambda: g.user.ethereum_address)
|
default=lambda: g.user.id)
|
||||||
proof_author = relationship(User, primaryjoin=lambda: ProofDataWipe.proof_author_id == User.ethereum_address)
|
proof_author = relationship(User, primaryjoin=lambda: ProofDataWipe.proof_author_id == User.id)
|
||||||
erasure_id = Column(UUID(as_uuid=True), ForeignKey(EraseBasic.id), nullable=False)
|
erasure_id = Column(UUID(as_uuid=True), ForeignKey(EraseBasic.id), nullable=False)
|
||||||
erasure = relationship(EraseBasic,
|
erasure = relationship(EraseBasic,
|
||||||
backref=backref('proof_datawipe',
|
backref=backref('proof_datawipe',
|
||||||
|
@ -118,11 +118,11 @@ class ProofDataWipe(JoinedTableMixin, Proof):
|
||||||
|
|
||||||
class ProofFunction(JoinedTableMixin, Proof):
|
class ProofFunction(JoinedTableMixin, Proof):
|
||||||
disk_usage = Column(db.Integer, default=0)
|
disk_usage = Column(db.Integer, default=0)
|
||||||
proof_author_id = Column(CIText(),
|
proof_author_id = Column(UUID(as_uuid=True),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.id),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=lambda: g.user.ethereum_address)
|
default=lambda: g.user.id)
|
||||||
proof_author = db.relationship(User, primaryjoin=lambda: ProofFunction.proof_author_id == User.ethereum_address)
|
proof_author = db.relationship(User, primaryjoin=lambda: ProofFunction.proof_author_id == User.id)
|
||||||
rate_id = Column(UUID(as_uuid=True), ForeignKey(Rate.id), nullable=False)
|
rate_id = Column(UUID(as_uuid=True), ForeignKey(Rate.id), nullable=False)
|
||||||
rate = relationship(Rate,
|
rate = relationship(Rate,
|
||||||
backref=backref('proof_function',
|
backref=backref('proof_function',
|
||||||
|
@ -135,15 +135,15 @@ class ProofFunction(JoinedTableMixin, Proof):
|
||||||
class ProofReuse(JoinedTableMixin, Proof):
|
class ProofReuse(JoinedTableMixin, Proof):
|
||||||
receiver_segment = Column(CIText(), default='', nullable=False)
|
receiver_segment = Column(CIText(), default='', nullable=False)
|
||||||
id_receipt = Column(CIText(), default='', nullable=False)
|
id_receipt = Column(CIText(), default='', nullable=False)
|
||||||
supplier_id = db.Column(CIText(),
|
supplier_id = db.Column(UUID(as_uuid=True),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.id),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=lambda: g.user.ethereum_address)
|
default=lambda: g.user.id)
|
||||||
supplier = db.relationship(User, primaryjoin=lambda: ProofReuse.supplier_id == User.ethereum_address)
|
supplier = db.relationship(User, primaryjoin=lambda: ProofReuse.supplier_id == User.id)
|
||||||
receiver_id = db.Column(CIText(),
|
receiver_id = db.Column(UUID(as_uuid=True),
|
||||||
db.ForeignKey(User.ethereum_address),
|
db.ForeignKey(User.id),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
receiver = db.relationship(User, primaryjoin=lambda: ProofReuse.receiver_id == User.ethereum_address)
|
receiver = db.relationship(User, primaryjoin=lambda: ProofReuse.receiver_id == User.id)
|
||||||
price = Column(db.Integer)
|
price = Column(db.Integer)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,31 +21,34 @@ class Proof(Thing):
|
||||||
ethereum_hash = SanitizedStr(default='', validate=Length(max=STR_BIG_SIZE),
|
ethereum_hash = SanitizedStr(default='', validate=Length(max=STR_BIG_SIZE),
|
||||||
data_key="ethereumHash", required=True)
|
data_key="ethereumHash", required=True)
|
||||||
url = URL(dump_only=True, description=m.Proof.url.__doc__)
|
url = URL(dump_only=True, description=m.Proof.url.__doc__)
|
||||||
device = NestedOn(s_device.Device, only_query='id', required=True, data_key='deviceID')
|
device_id = Integer(load_only=True, data_key='deviceID')
|
||||||
|
device = NestedOn(s_device.Device, dump_only=True)
|
||||||
|
|
||||||
|
|
||||||
class ProofTransfer(Proof):
|
class ProofTransfer(Proof):
|
||||||
__doc__ = m.ProofTransfer.__doc__
|
__doc__ = m.ProofTransfer.__doc__
|
||||||
deposit = Integer()
|
deposit = Integer(validate=f.validate.Range(min=0, max=100))
|
||||||
supplier_id = SanitizedStr(validate=f.validate.Length(max=STR_SIZE),
|
supplier_id = UUID(load_only=True, required=True, data_key='supplierID')
|
||||||
load_only=True, required=True, data_key='supplierID')
|
receiver_id = UUID(load_only=True, required=True, data_key='receiverID')
|
||||||
receiver_id = SanitizedStr(validate=f.validate.Length(max=STR_SIZE),
|
|
||||||
load_only=True, required=True, data_key='receiverID')
|
|
||||||
|
|
||||||
|
|
||||||
class ProofDataWipe(Proof):
|
class ProofDataWipe(Proof):
|
||||||
__doc__ = m.ProofDataWipe.__doc__
|
__doc__ = m.ProofDataWipe.__doc__
|
||||||
erasure_type = String(default='', data_key='erasureType')
|
# erasure_type = String(default='', data_key='erasureType')
|
||||||
date = DateTime('iso', required=True)
|
date = DateTime('iso', required=True)
|
||||||
result = Boolean(required=True)
|
result = Boolean(required=True)
|
||||||
proof_author = NestedOn(s_user.User, only_query='id', data_key='proofAuthor')
|
proof_author_id = SanitizedStr(validate=f.validate.Length(max=STR_SIZE),
|
||||||
|
load_only=True, required=True, data_key='proofAuthor')
|
||||||
|
proof_author = NestedOn(s_user.User, dump_only=True)
|
||||||
erasure = NestedOn(s_action.EraseBasic, only_query='id', data_key='erasureID')
|
erasure = NestedOn(s_action.EraseBasic, only_query='id', data_key='erasureID')
|
||||||
|
|
||||||
|
|
||||||
class ProofFunction(Proof):
|
class ProofFunction(Proof):
|
||||||
__doc__ = m.ProofFunction.__doc__
|
__doc__ = m.ProofFunction.__doc__
|
||||||
disk_usage = Integer(data_key='diskUsage')
|
disk_usage = Integer(validate=f.validate.Range(min=0, max=100), data_key='diskUsage')
|
||||||
proof_author = NestedOn(s_user.User, only_query='id', data_key='proofAuthor')
|
proof_author_id = SanitizedStr(validate=f.validate.Length(max=STR_SIZE),
|
||||||
|
load_only=True, required=True, data_key='proofAuthor')
|
||||||
|
proof_author = NestedOn(s_user.User, dump_only=True)
|
||||||
rate = NestedOn(s_action.Rate, required=True,
|
rate = NestedOn(s_action.Rate, required=True,
|
||||||
only_query='id', data_key='rateID')
|
only_query='id', data_key='rateID')
|
||||||
|
|
||||||
|
@ -54,8 +57,8 @@ class ProofReuse(Proof):
|
||||||
__doc__ = m.ProofReuse.__doc__
|
__doc__ = m.ProofReuse.__doc__
|
||||||
receiver_segment = String(default='', data_key='receiverSegment', required=True)
|
receiver_segment = String(default='', data_key='receiverSegment', required=True)
|
||||||
id_receipt = String(default='', data_key='idReceipt', required=True)
|
id_receipt = String(default='', data_key='idReceipt', required=True)
|
||||||
supplier = NestedOn(s_user.User, only_query='ethereum_address', required=True, data_key='supplierAddress')
|
supplier_id = UUID(load_only=True, required=True, data_key='supplierID')
|
||||||
receiver = NestedOn(s_user.User, only_query='ethereum_address', required=True, data_key='receiverAddress')
|
receiver_id = UUID(load_only=True, required=True, data_key='receiverID')
|
||||||
price = Integer(required=True)
|
price = Integer(required=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,9 @@ class ProofView(View):
|
||||||
Model = db.Model._decl_class_registry.data[prf['type']]()
|
Model = db.Model._decl_class_registry.data[prf['type']]()
|
||||||
proof = Model(**p)
|
proof = Model(**p)
|
||||||
db.session.add(proof)
|
db.session.add(proof)
|
||||||
db.session.commit()
|
proofs.append(resource_def.schema.dump(proof))
|
||||||
proofs.append(self.schema.dump(proof))
|
db.session().final_flush()
|
||||||
|
db.session.commit()
|
||||||
response = jsonify({
|
response = jsonify({
|
||||||
'items': proofs,
|
'items': proofs,
|
||||||
'url': request.path
|
'url': request.path
|
||||||
|
|
Reference in New Issue