forked from mirrors/bookwyrm
Forgot to add the migration and models helper
This commit is contained in:
parent
71027a1459
commit
3e434077f9
2 changed files with 96 additions and 0 deletions
75
fedireads/migrations/0002_auto_20200217_0309.py
Normal file
75
fedireads/migrations/0002_auto_20200217_0309.py
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
# Generated by Django 3.0.3 on 2020-02-17 03:09
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('fedireads', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='author',
|
||||||
|
old_name='added_date',
|
||||||
|
new_name='created_date',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='book',
|
||||||
|
old_name='added_date',
|
||||||
|
new_name='created_date',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='author',
|
||||||
|
name='updated_date',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='book',
|
||||||
|
name='updated_date',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='shelf',
|
||||||
|
name='updated_date',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='user',
|
||||||
|
name='created_date',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='user',
|
||||||
|
name='updated_date',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='author',
|
||||||
|
name='content',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='book',
|
||||||
|
name='content',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='federatedserver',
|
||||||
|
name='content',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='federatedserver',
|
||||||
|
name='created_date',
|
||||||
|
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='shelf',
|
||||||
|
name='content',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='shelfbook',
|
||||||
|
name='content',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
21
fedireads/utils/models.py
Normal file
21
fedireads/utils/models.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from fedireads.settings import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
class FedireadsModel(models.Model):
|
||||||
|
content = models.TextField(blank=True, null=True)
|
||||||
|
created_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def absolute_id(self):
|
||||||
|
''' constructs the absolute reference to any db object '''
|
||||||
|
base_path = 'https://%s' % DOMAIN
|
||||||
|
if self.user:
|
||||||
|
base_path = self.user.absolute_id
|
||||||
|
model_name = type(self).__name__
|
||||||
|
return '%s/%s/%d' % (base_path, model_name, self.id)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
Loading…
Reference in a new issue