Changeset 1:353c0fb6a2b2
- Timestamp:
- 06/29/07 11:59:21 (5 years ago)
- Branch:
- default
- Location:
- textpress
- Files:
-
- 3 added
- 11 edited
-
models.py (modified) (2 diffs)
-
models.pyc (modified) (previous)
-
shared/admin/style.css (modified) (2 diffs)
-
templates/admin/delete_post.html (added)
-
templates/admin/delete_tag.html (added)
-
templates/admin/edit_post.html (modified) (1 diff)
-
templates/admin/edit_tag.html (modified) (1 diff)
-
templates/admin/show_users.html (added)
-
urls.py (modified) (1 diff)
-
urls.pyc (modified) (previous)
-
views/__init__.py (modified) (1 diff)
-
views/__init__.pyc (modified) (previous)
-
views/admin.py (modified) (7 diffs)
-
views/admin.pyc (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
textpress/models.py
r0 r1 550 550 primaryjoin=comments.c.parent_id == comments.c.comment_id, 551 551 cascade='all', order_by=[db.asc(comments.c.pub_date)], 552 backref=db.backref('parent', remote_side=[comments.c.comment_id]) 552 backref=db.backref('parent', remote_side=[comments.c.comment_id]), 553 lazy=True 553 554 ) 554 555 }, order_by=[db.desc(comments.c.pub_date)]) … … 560 561 'tags': db.relation(Tag, secondary=post_tags, lazy=False, 561 562 order_by=[db.asc(tags.c.name)], 562 cascade='all ', backref='posts')563 cascade='all, expunge', backref='posts') 563 564 }, order_by=[db.desc(posts.c.pub_date)]) -
textpress/shared/admin/style.css
r0 r1 205 205 } 206 206 207 div.contents input[name="delete"]:hover { 208 background-color: #d00; 209 color: white; 210 } 211 207 212 div.contents fieldset { 208 213 margin: 10px 0 0 0; … … 280 285 div.contents table tr.even { 281 286 background-color: #f2f2f2; 287 } 288 289 p.preview { 290 text-align: right; 282 291 } 283 292 -
textpress/templates/admin/edit_post.html
r0 r1 80 80 </fieldset> 81 81 {%- endif %} 82 {% if not new_post %} 83 <p class="preview"> 84 <a href="{{ url_for(post) }}">{% trans "View Post" %}</a> 85 </p> 86 {% endif %} 82 87 <div class="actions"> 83 88 <input type="submit" name="save_and_new" value="{% trans 'Save' %}"> 84 89 <input type="submit" name="save_and_continue" value="{% trans 'Save and continue editing' %}"> 90 {%- if not new_post %} 91 <input type="submit" name="delete" value="{% trans 'Delete' %}"> 92 {%- endif %} 85 93 <input type="submit" name="cancel" value="{% trans 'Cancel' %}"> 86 94 </div> -
textpress/templates/admin/edit_tag.html
r0 r1 28 28 <div class="actions"> 29 29 <input type="submit" value="{% trans 'Save' %}"> 30 <input type="submit" name="delete" value="{% trans 'Delete' %}"> 30 31 <input type="submit" name="cancel" value="{% trans 'Cancel' %}"> 31 32 </div> -
textpress/urls.py
r0 r1 35 35 Rule('/posts/new', endpoint='admin/new_post'), 36 36 Rule('/posts/<int:post_id>', endpoint='admin/edit_post'), 37 Rule('/posts/<int:post_id>/delete', endpoint='admin/delete_post'), 37 38 Rule('/tags/', endpoint='admin/show_tags'), 38 39 Rule('/tags/new', endpoint='admin/new_tag'), 39 Rule('/tags/<int:tag_id>', endpoint='admin/edit_tag') 40 Rule('/tags/<int:tag_id>', endpoint='admin/edit_tag'), 41 Rule('/tags/<int:tag_id>/delete', endpoint='admin/delete_tag'), 42 Rule('/users/', endpoint='admin/show_users'), 43 Rule('/users/new', endpoint='admin/new_user'), 44 Rule('/users/<int:user_id>', endpoint='admin/edit_user'), 45 Rule('/users/<int:user_id>/delete', endpoint='admin/delete_user') 40 46 ]) 41 47 ] -
textpress/views/__init__.py
r0 r1 30 30 'admin/new_post': admin.do_edit_post, 31 31 'admin/edit_post': admin.do_edit_post, 32 'admin/delete_post': admin.do_delete_post, 32 33 'admin/show_tags': admin.do_show_tags, 33 34 'admin/new_tag': admin.do_edit_tag, 34 35 'admin/edit_tag': admin.do_edit_tag, 36 'admin/delete_tag': admin.do_delete_tag, 37 'admin/show_users': admin.do_show_users, 38 'admin/new_user': admin.do_edit_user, 39 'admin/edit_user': admin.do_edit_user, 40 'admin/delete_user': admin.do_delete_user, 35 41 'admin/login': admin.do_login, 36 42 'admin/logout': admin.do_logout -
textpress/views/admin.py
r0 r1 33 33 ('overview', url_for('admin/show_tags'), _('Overview')), 34 34 ('edit', url_for('admin/new_tag'), _('Edit Tag')) 35 ]), 36 ('users', url_for('admin/show_users'), _('Users'), [ 37 ('overview', url_for('admin/show_users'), _('Users')), 38 ('edit', url_for('admin/new_user'), _('Edit User')) 35 39 ]) 36 40 ] … … 69 73 errors = [] 70 74 form = {} 75 post=None 71 76 72 77 # edit existing post … … 110 115 redirect(url_for('admin/show_posts')) 111 116 117 # handle delete, redirect to confirmation page 118 if req.form.get('delete') and post_id is not None: 119 redirect(url_for('admin/delete_post', post_id=post_id)) 120 112 121 form['title'] = title = req.form.get('title') 113 122 if not title: … … 197 206 tags=Tag.select(), 198 207 created=created, 208 new_post=new_post, 209 post=post, 199 210 post_status_choices=[ 200 211 (STATUS_PUBLISHED, _('Published')), … … 203 214 ] 204 215 ) 216 217 218 def do_delete_post(req, post_id): 219 post = Post.get(post_id) 220 if post is None: 221 redirect(url_for('admin/show_posts')) 222 223 if req.method == 'POST': 224 if req.form.get('cancel'): 225 redirect(url_for('admin/edit_post', post_id=post.post_id)) 226 elif req.form.get('confirm'): 227 post.delete() 228 db.flush() 229 redirect(url_for('admin/show_posts')) 230 231 return render_admin_response('admin/delete_post.html', post=post) 205 232 206 233 … … 229 256 230 257 if req.method == 'POST': 258 # cancel 231 259 if req.form.get('cancel'): 232 260 redirect(url_for('admin/show_tags')) 261 262 # delete 263 if req.form.get('delete'): 264 redirect(url_for('admin/delete_tag', tag_id=tag.tag_id)) 233 265 234 266 form['slug'] = slug = req.form.get('slug') … … 256 288 form=form 257 289 ) 290 291 292 def do_delete_tag(req, tag_id): 293 tag = Tag.get(tag_id) 294 if tag is None: 295 redirect(url_for('admin/show_tags')) 296 297 if req.method == 'POST': 298 if req.form.get('cancel'): 299 redirect(url_for('admin/edit_tag', tag_id=tag.tag_id)) 300 elif req.form.get('confirm'): 301 tag.delete() 302 db.flush() 303 redirect(url_for('admin/show_tags')) 304 305 return render_admin_response('admin/delete_tag.html', tag=tag) 306 307 308 def do_show_users(req): 309 return render_admin_response('admin/show_users.html', users=User.select()) 310 311 312 def do_edit_user(req, user_id=None): 313 pass 314 315 316 def do_delete_user(req, user_id): 317 pass 258 318 259 319
Note: See TracChangeset
for help on using the changeset viewer.