mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 06:34:25 -04:00
move snapshot id to old_id
This commit is contained in:
parent
951025228f
commit
8c50257fe9
3 changed files with 26 additions and 6 deletions
|
@ -20,7 +20,7 @@ from signal_webhooks.admin import WebhookAdmin, get_webhook_model
|
||||||
|
|
||||||
from ..util import htmldecode, urldecode, ansi_to_html
|
from ..util import htmldecode, urldecode, ansi_to_html
|
||||||
|
|
||||||
from core.models import Snapshot, ArchiveResult, Tag
|
from core.models import Snapshot, ArchiveResult, Tag, SnapshotTag
|
||||||
from core.forms import AddLinkForm
|
from core.forms import AddLinkForm
|
||||||
|
|
||||||
from core.mixins import SearchResultsAdminMixin
|
from core.mixins import SearchResultsAdminMixin
|
||||||
|
@ -125,9 +125,14 @@ archivebox_admin.get_urls = get_urls(archivebox_admin.get_urls).__get__(archiveb
|
||||||
|
|
||||||
class ArchiveResultInline(admin.TabularInline):
|
class ArchiveResultInline(admin.TabularInline):
|
||||||
model = ArchiveResult
|
model = ArchiveResult
|
||||||
|
fk_name = 'snapshot'
|
||||||
|
|
||||||
class TagInline(admin.TabularInline):
|
class TagInline(admin.TabularInline):
|
||||||
model = Snapshot.tags.through
|
model = Snapshot.tags.through
|
||||||
|
# fk_name = 'snapshottag'
|
||||||
|
|
||||||
|
def identifiers(self, obj):
|
||||||
|
return '-'
|
||||||
|
|
||||||
from django.contrib.admin.helpers import ActionForm
|
from django.contrib.admin.helpers import ActionForm
|
||||||
from django.contrib.admin.widgets import AutocompleteSelectMultiple
|
from django.contrib.admin.widgets import AutocompleteSelectMultiple
|
||||||
|
@ -449,6 +454,17 @@ class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# @admin.register(SnapshotTag, site=archivebox_admin)
|
||||||
|
# class SnapshotTagAdmin(admin.ModelAdmin):
|
||||||
|
# list_display = ('id', 'snapshot', 'tag')
|
||||||
|
# sort_fields = ('id', 'snapshot', 'tag')
|
||||||
|
# search_fields = ('id', 'snapshot_id', 'tag_id')
|
||||||
|
# fields = ('snapshot', 'id')
|
||||||
|
# actions = ['delete_selected']
|
||||||
|
# ordering = ['-id']
|
||||||
|
|
||||||
|
# def identifiers(self, obj):
|
||||||
|
# return get_abid_info(self, obj)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Tag, site=archivebox_admin)
|
@admin.register(Tag, site=archivebox_admin)
|
||||||
|
|
|
@ -114,16 +114,19 @@ class Tag(ABIDModel):
|
||||||
def api_docs_url(self) -> str:
|
def api_docs_url(self) -> str:
|
||||||
return f'/api/v1/docs#/Core%20Models/api_v1_core_get_tag'
|
return f'/api/v1/docs#/Core%20Models/api_v1_core_get_tag'
|
||||||
|
|
||||||
|
class SnapshotTag(models.Model):
|
||||||
|
snapshot = models.OneToOneField('Snapshot', primary_key=True, on_delete=models.CASCADE, to_field='id')
|
||||||
|
tag = models.ForeignKey(Tag, on_delete=models.CASCADE, to_field='id')
|
||||||
|
|
||||||
class Snapshot(ABIDModel):
|
class Snapshot(ABIDModel):
|
||||||
abid_prefix = 'snp_'
|
abid_prefix = 'snp_'
|
||||||
abid_ts_src = 'self.added'
|
abid_ts_src = 'self.added'
|
||||||
abid_uri_src = 'self.url'
|
abid_uri_src = 'self.url'
|
||||||
abid_subtype_src = '"01"'
|
abid_subtype_src = '"01"'
|
||||||
abid_rand_src = 'self.id'
|
abid_rand_src = 'self.old_id'
|
||||||
|
|
||||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # legacy pk
|
old_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # legacy pk
|
||||||
uuid = models.UUIDField(default=uuid.uuid4, editable=True, unique=True)
|
id = models.UUIDField(default=uuid.uuid4, editable=True, unique=True)
|
||||||
abid = ABIDField(prefix=abid_prefix)
|
abid = ABIDField(prefix=abid_prefix)
|
||||||
|
|
||||||
url = models.URLField(unique=True, db_index=True)
|
url = models.URLField(unique=True, db_index=True)
|
||||||
|
@ -351,7 +354,8 @@ class ArchiveResult(ABIDModel):
|
||||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True, unique=True, verbose_name='ID')
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True, unique=True, verbose_name='ID')
|
||||||
abid = ABIDField(prefix=abid_prefix)
|
abid = ABIDField(prefix=abid_prefix)
|
||||||
|
|
||||||
snapshot = models.ForeignKey(Snapshot, on_delete=models.CASCADE)
|
snapshot = models.ForeignKey(Snapshot, on_delete=models.CASCADE, to_field='id')
|
||||||
|
|
||||||
extractor = models.CharField(choices=EXTRACTOR_CHOICES, max_length=32)
|
extractor = models.CharField(choices=EXTRACTOR_CHOICES, max_length=32)
|
||||||
cmd = models.JSONField()
|
cmd = models.JSONField()
|
||||||
pwd = models.CharField(max_length=256)
|
pwd = models.CharField(max_length=256)
|
||||||
|
|
|
@ -266,7 +266,7 @@ class Link:
|
||||||
@cached_property
|
@cached_property
|
||||||
def snapshot(self):
|
def snapshot(self):
|
||||||
from core.models import Snapshot
|
from core.models import Snapshot
|
||||||
return Snapshot.objects.only('uuid').get(url=self.url)
|
return Snapshot.objects.only('id').get(url=self.url)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def snapshot_id(self):
|
def snapshot_id(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue