kopia lustrzana https://gitlab.com/marnanel/chapeau
"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
rodzic
f480aa71d0
commit
0259daf3ed
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -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.',
|
||||
|
|
Ładowanie…
Reference in New Issue