"url" param of trilby's Person renamed to "remote_url" per policy; "status" field or attribute removed in both Person subclasses.

It was getting too confusing to store people who don't exist in Person. See sombrero's Failure for where they went.
status-serialisers
Marnanel Thurman 2020-10-19 16:51:11 +01:00
rodzic f480aa71d0
commit 0259daf3ed
2 zmienionych plików z 42 dodań i 19 usunięć

Wyświetl plik

@ -0,0 +1,22 @@
# Generated by Django 3.0.9 on 2020-10-19 15:24
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('trilby_api', '0025_auto_20201011_1439'),
]
operations = [
migrations.RenameField(
model_name='remoteperson',
old_name='url',
new_name='remote_url',
),
migrations.RemoveField(
model_name='remoteperson',
name='status',
),
]

Wyświetl plik

@ -123,24 +123,13 @@ class Person(PolymorphicModel):
class RemotePerson(Person):
url = models.URLField(
remote_url = models.URLField(
max_length = 255,
unique = True,
null = True,
blank = True,
)
status = models.IntegerField(
default = 0,
choices = [
(0, 'pending'),
(200, 'found'),
(404, 'not found'),
(410, 'gone'),
(500, 'remote error'),
],
)
found_at = models.DateTimeField(
null = True,
default = None,
@ -236,6 +225,10 @@ class RemotePerson(Person):
blank = True,
)
@property
def url(self):
return self.remote_url
@property
def is_local(self):
return False
@ -280,12 +273,24 @@ class RemotePerson(Person):
self.address = address
def __iter__(self):
self.collection = fetch(
remote_collection = fetch(
self.address,
Collection,
).__iter__()
)
if remote_collection is None:
logger.debug(
"%s RemotePerson: could not retrieve collection",
self.address,
)
self.collection = [].__iter__()
return self
self.collection = remote_collection.__iter__()
logger.debug(
"%s RemotePerson: retrieved collection %s",
"%s: retrieved collection %s",
self.address,
self.collection,
)
@ -401,10 +406,6 @@ class LocalPerson(Person):
blank = True,
)
@property
def status(self):
return 200 # necessarily
def _generate_keys(self):
logger.info('%s: generating key pair.',