some final changes
Getty Ritter
3 years ago
11 | 11 | CATEGORIES[c_id] = model.Category.create(name=name, nicename=nicename) |
12 | 12 | |
13 | 13 | 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 | ) | |
22 | 23 | |
23 | for (_, filename, d_id) in c.execute("SELECT * FROM photos"): | |
24 | if d_id in DESIGNS: | |
25 |
|
|
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]) | |
26 | 28 | |
27 | for (_, name, d_id) in c.execute("SELECT * FROM tags"): | |
28 | if d_id in DESIGNS: | |
29 |
|
|
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]) | |
30 | 33 | |
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) | |
33 | 37 | |
34 | 38 | |
35 | 39 | if __name__ == "__main__": |
183 | 183 | "categories": design.category_list(), |
184 | 184 | "description": design.description, |
185 | 185 | "photos": design.photos, |
186 |
"id_str": f"{design. |
|
186 | "id_str": f"{design.visible_id:05}", | |
187 | 187 | } |
188 | 188 | ), |
189 | 189 | ) |
232 | 232 | if id == -1: |
233 | 233 | return flask.redirect(f"/edit/view-photo/{photo_id}") |
234 | 234 | else: |
235 |
return flask.redirect(f"/edit/design/{ |
|
235 | return flask.redirect(f"/edit/design/{id}") | |
236 | 236 | |
237 | 237 | |
238 | 238 | @app.route("/edit/photo/<id>/") |
133 | 133 | |
134 | 134 | @classmethod |
135 | 135 | def upload(klass, upload, design_id): |
136 | design = Design.get(visible_id=design_id) | |
136 | 137 | last_image = klass.select().order_by(klass.filename.desc()).limit(1) |
137 | 138 | if last_image: |
138 | 139 | n = int(last_image[0].filename[:5]) + 1 |
151 | 152 | |
152 | 153 | klass.create( |
153 | 154 | filename=full_name, |
154 |
design=design |
|
155 | design=design, | |
155 | 156 | ) |
156 | 157 | |
157 | 158 | return full_name |
182 | 182 | width: min-content; |
183 | 183 | margin-left: auto; |
184 | 184 | margin-right: auto; |
185 |
align-items: |
|
185 | align-items: stretch; | |
186 | 186 | } |
187 | 187 | |
188 | 188 | .image_edit { |
189 | 189 | border: 1px solid #000; |
190 | 190 | 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 | ||
193 | 202 | |
194 | 203 | .design .description { |
195 | 204 | max-width: 80%; |
308 | 317 | left: 50%; |
309 | 318 | transform: translate(-50%, -50%); |
310 | 319 | } |
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 | } |
41 | 41 | <div class="image_edit"> |
42 | 42 | <img src="/static/photos/{{filename}}"/><br/> |
43 | 43 | <a href="/edit/view-photo/{{filename}}">{{filename}}</a> — |
44 |
<a href="/edit/photo/{{filename}}?design_id={{id |
|
44 | <a href="/edit/photo/{{filename}}?design_id={{id_str}}">Delete this image</a> | |
45 | 45 | </div> |
46 | 46 | {{/photos}} |
47 | <div class="image_edit add_image"> | |
48 | <a href="/edit/photo/?id={{id}}"><h2>New Photo</h2></a> | |
49 | </div> | |
47 | 50 | </div> |
48 | 51 | </div> |
49 | 52 | </form> |
26 | 26 | <a href="http://blog.fronyritterdesigns.com/">Blog</a> |
27 | 27 | <a href="/wheretobuy">Where To Buy</a> |
28 | 28 | <a href="/retailinfo">Info For Retailers</a> |
29 | <a href="/corrections/">Corrections</a> | |
30 | 29 | <a href="/about/">About</a> |
31 | 30 | </div> |
32 | 31 | <div id="sidebyside"> |
70 | 69 | </ul> |
71 | 70 | |
72 | 71 | <a href="/category/gallery"><li class="topitem">Stitchers' Gallery</li></a> |
72 | <a href="/corrections/"><li class="topitem">Stitchers' Gallery</li></a> | |
73 | 73 | |
74 | 74 | |
75 | 75 | </ul> |