feat(api/db); add hash_id order field (#763)

This commit is contained in:
Reckless_Satoshi 2023-08-03 09:51:41 +00:00 committed by GitHub
parent 0c37767d68
commit 00628413f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -263,7 +263,6 @@ class OrderAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
order.status in [Order.Status.DIS, Order.Status.WFR]
and order.is_disputed
):
order.maker.robot.earned_rewards = order.maker_bond.num_satoshis
order.maker.robot.save(update_fields=["earned_rewards"])
order.taker.robot.earned_rewards = order.taker_bond.num_satoshis
@ -421,7 +420,7 @@ class UserRobotAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
change_links = ["user"]
readonly_fields = ["avatar_tag"]
search_fields = ["user__username", "id"]
readonly_fields = ("public_key", "encrypted_private_key")
readonly_fields = ("hash_id", "public_key", "encrypted_private_key")
@admin.register(Currency)

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2.2 on 2023-07-18 17:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("api", "0039_alter_currency_currency"),
]
operations = [
migrations.AddField(
model_name="robot",
name="hash_id",
field=models.CharField(
blank=True, default=None, max_length=64, null=True, unique=True
),
),
]

View File

@ -12,6 +12,15 @@ from django.utils.html import mark_safe
class Robot(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
# Hash id (second sha256 of robot token)
hash_id = models.CharField(
max_length=64,
unique=True,
default=None,
blank=True,
null=True,
)
# PGP keys, used for E2E chat encryption. Priv key is encrypted with user's passphrase (highEntropyToken)
public_key = models.TextField(
# Actually only 400-500 characters for ECC, but other types might be longer