gdritter repos frony-ritter-designs / 854db81
some final changes Getty Ritter 3 years ago
7 changed file(s) with 61 addition(s) and 24 deletion(s). Collapse all Expand all
1111 CATEGORIES[c_id] = model.Category.create(name=name, nicename=nicename)
1212
1313 DESIGNS = {}
14 for row in c.execute("SELECT * FROM designs"):
15 (id, title, description, category) = row
16 DESIGNS[id] = model.Design.create(
17 visible_id=id,
18 title=title,
19 description=description,
20 category=CATEGORIES[category],
21 )
14 with model.db.atomic():
15 for row in c.execute("SELECT * FROM designs"):
16 (id, title, description, category) = row
17 DESIGNS[id] = model.Design.create(
18 visible_id=id,
19 title=title,
20 description=description,
21 category=CATEGORIES[category],
22 )
2223
23 for (_, filename, d_id) in c.execute("SELECT * FROM photos"):
24 if d_id in DESIGNS:
25 model.Photo.create(filename=filename, design=DESIGNS[d_id])
24 with model.db.atomic():
25 for (_, filename, d_id) in c.execute("SELECT * FROM photos"):
26 if d_id in DESIGNS:
27 model.Photo.create(filename=filename, design=DESIGNS[d_id])
2628
27 for (_, name, d_id) in c.execute("SELECT * FROM tags"):
28 if d_id in DESIGNS:
29 model.Tag.create(tag_name=name, design=DESIGNS[d_id])
29 with model.db.atomic():
30 for (_, name, d_id) in c.execute("SELECT * FROM tags"):
31 if d_id in DESIGNS:
32 model.Tag.create(tag_name=name, design=DESIGNS[d_id])
3033
31 for (_, name, text, title) in c.execute("SELECT * FROM pages"):
32 model.Page.create(name=name, text=text, title=title)
34 with model.db.atomic():
35 for (_, name, text, title) in c.execute("SELECT * FROM pages"):
36 model.Page.create(name=name, text=text, title=title)
3337
3438
3539 if __name__ == "__main__":
183183 "categories": design.category_list(),
184184 "description": design.description,
185185 "photos": design.photos,
186 "id_str": f"{design.id:05}",
186 "id_str": f"{design.visible_id:05}",
187187 }
188188 ),
189189 )
232232 if id == -1:
233233 return flask.redirect(f"/edit/view-photo/{photo_id}")
234234 else:
235 return flask.redirect(f"/edit/design/{photo_id}")
235 return flask.redirect(f"/edit/design/{id}")
236236
237237
238238 @app.route("/edit/photo/<id>/")
133133
134134 @classmethod
135135 def upload(klass, upload, design_id):
136 design = Design.get(visible_id=design_id)
136137 last_image = klass.select().order_by(klass.filename.desc()).limit(1)
137138 if last_image:
138139 n = int(last_image[0].filename[:5]) + 1
151152
152153 klass.create(
153154 filename=full_name,
154 design=design_id,
155 design=design,
155156 )
156157
157158 return full_name
182182 width: min-content;
183183 margin-left: auto;
184184 margin-right: auto;
185 align-items: center;
185 align-items: stretch;
186186 }
187187
188188 .image_edit {
189189 border: 1px solid #000;
190190 padding: 1em;
191 text-align: center;
192 }
191 margin: 1em;
192 text-align: center;
193 }
194
195 .add_image {
196 width: 200px;
197 display: flex;
198 align-items: center;
199 justify-content: center;
200 }
201
193202
194203 .design .description {
195204 max-width: 80%;
308317 left: 50%;
309318 transform: translate(-50%, -50%);
310319 }
320
321 .wk-commands {
322 border: 1px solid black;
323 display: flex;
324 justify-content: space-evenly;
325 }
326
327 .wk-command {
328 }
329
330 .wk-switchboard {
331 display: none;
332 }
4141 <div class="image_edit">
4242 <img src="/static/photos/{{filename}}"/><br/>
4343 <a href="/edit/view-photo/{{filename}}">{{filename}}</a> &mdash;
44 <a href="/edit/photo/{{filename}}?design_id={{id}}">Delete this image</a>
44 <a href="/edit/photo/{{filename}}?design_id={{id_str}}">Delete this image</a>
4545 </div>
4646 {{/photos}}
47 <div class="image_edit add_image">
48 <a href="/edit/photo/?id={{id}}"><h2>New Photo</h2></a>
49 </div>
4750 </div>
4851 </div>
4952 </form>
2626 <a href="http://blog.fronyritterdesigns.com/">Blog</a>
2727 <a href="/wheretobuy">Where To Buy</a>
2828 <a href="/retailinfo">Info For Retailers</a>
29 <a href="/corrections/">Corrections</a>
3029 <a href="/about/">About</a>
3130 </div>
3231 <div id="sidebyside">
7069 </ul>
7170
7271 <a href="/category/gallery"><li class="topitem">Stitchers' Gallery</li></a>
72 <a href="/corrections/"><li class="topitem">Stitchers' Gallery</li></a>
7373
7474
7575 </ul>
1 <img src="" />
2 Do you really want to delete this image?
3 <form name="img-delete" method="post" action="/edit/photo/{{id}}/">
4 <input type="hidden" name="design_id" value="{{design_id}}" />
5 <input type="submit" value="Yes"/>
6 </form>
7 <a href="/edit/design/{{design_id}}/">No</a>