gdritter repos frony-ritter-designs / 7cfd12e
allow photos to not have a design Getty Ritter 3 years ago
1 changed file(s) with 12 addition(s) and 2 deletion(s). Collapse all Expand all
120120
121121 class Photo(Model):
122122 filename = peewee.TextField()
123 design = peewee.ForeignKeyField(Design, backref="photos")
123 design = peewee.ForeignKeyField(Design, backref="photos", null=True)
124124
125125 def thumb(self):
126126 return self.filename[:-4] + "_thumb" + self.filename[-4:]
133133
134134 @classmethod
135135 def upload(klass, upload, design_id):
136 design = Design.get(visible_id=design_id)
137136 last_image = klass.select().order_by(klass.filename.desc()).limit(1)
138137 if last_image:
139138 n = int(last_image[0].filename[:5]) + 1
150149 img.thumbnail((100, 100), PIL.Image.ANTIALIAS)
151150 img.save(os.path.join(os.getcwd(), "static", "photos", thumb_name))
152151
152 if design_id != -1:
153 design = Design.get(visible_id=design_id)
154 else:
155 design = None
153156 klass.create(
154157 filename=full_name,
155158 design=design,
208211 contents=contents,
209212 )
210213
214 MODELS = [
215 Category,
216 Design,
217 Photo,
218 Page,
219 Tag,
220 ]
211221
212222 # @dataclass
213223 # class Paginated: