File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from .models import Showcase , ShowcaseSiteSettings
44
55
6- admin .site .register (Showcase )
6+ class ShowcaseAdmin (admin .ModelAdmin ):
7+ readonly_fields = ('hash' ,)
8+
9+
10+ admin .site .register (Showcase , ShowcaseAdmin )
711admin .site .register (ShowcaseSiteSettings )
Original file line number Diff line number Diff line change 1+ # Generated by Django 3.1.8 on 2021-09-07 08:58
2+
3+ from django .db import migrations , models
4+ import uuid
5+
6+
7+ class Migration (migrations .Migration ):
8+
9+ dependencies = [
10+ ('showcase' , '0002_showcasesitesettings' ),
11+ ]
12+
13+ operations = [
14+ migrations .AddField (
15+ model_name = 'showcase' ,
16+ name = 'hash' ,
17+ field = models .UUIDField (default = uuid .uuid4 , editable = False ),
18+ ),
19+ ]
Original file line number Diff line number Diff line change 1+ import uuid
2+
13from django .conf import settings
24from django .db import models
35
@@ -30,6 +32,7 @@ class Showcase(models.Model):
3032 "the project. Img should ideally be 500x800px." )
3133 )
3234 is_public = models .BooleanField (default = True )
35+ hash = models .UUIDField (default = uuid .uuid4 , editable = False )
3336
3437 def __str__ (self ):
3538 return self .display_name
@@ -55,6 +58,10 @@ def url(self):
5558 return (f'{ settings .ACCOUNT_DEFAULT_HTTP_PROTOCOL } ://'
5659 f'{ settings .ALLOWED_HOSTS [0 ]} /showcase/{ self .id } /' )
5760
61+ @property
62+ def image_url (self ):
63+ return f'{ self .url } image/{ self .hash .hex } /'
64+
5865
5966class SingletonModel (models .Model ):
6067 """ Singleton model for Showcases """
You can’t perform that action at this time.
0 commit comments