Last few touchups:
- Added a hint to the date fields. - Renamed the input fields.
This commit is contained in:
parent
424f406182
commit
30cbc8af0b
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
from scribeengine.lib.base import *
|
from scribeengine.lib.base import *
|
||||||
from scribeengine.lib import utils
|
from scribeengine.lib import utils
|
||||||
@ -61,23 +62,23 @@ class PostController(BaseController):
|
|||||||
|
|
||||||
@authenticate(u'Edit My Posts')
|
@authenticate(u'Edit My Posts')
|
||||||
def edit_POST(self, id=None):
|
def edit_POST(self, id=None):
|
||||||
url = utils.generate_url(c.form_values[u'edit-title'])
|
url = utils.generate_url(c.form_values[u'post-title'])
|
||||||
if id is None:
|
if id is None:
|
||||||
post = Post()
|
post = Post()
|
||||||
post.user = c.current_user
|
post.user = c.current_user
|
||||||
else:
|
else:
|
||||||
post = Session.query(Post).get(id)
|
post = Session.query(Post).get(id)
|
||||||
post.modified = datetime.now()
|
post.modified = datetime.now()
|
||||||
if c.form_values.get(u'authored') and c.form_values[u'authored']:
|
if c.form_values.get(u'post-authored') and c.form_values[u'post-authored']:
|
||||||
c.post.created = datetime(*time.strptime(c.form_values[u'authored'], '%Y/%m/%d %H:%M:%S'))
|
post.created = datetime(*time.strptime(c.form_values[u'post-authored'], '%Y/%m/%d %H:%M:%S')[0:6])
|
||||||
post.title = c.form_values[u'title']
|
post.title = c.form_values[u'post-title']
|
||||||
post.body = c.form_values[u'body']
|
post.body = c.form_values[u'post-body']
|
||||||
if c.form_values[u'action'] == u'Save Draft':
|
if c.form_values[u'post-action'] == u'Save Draft':
|
||||||
post.status = u'draft'
|
post.status = u'draft'
|
||||||
else:
|
else:
|
||||||
post.status = u'published'
|
post.status = u'published'
|
||||||
post.url = url
|
post.url = url
|
||||||
tags = c.form_values[u'tags']
|
tags = c.form_values[u'post-tags']
|
||||||
tag_list = [tag_name.strip() for tag_name in tags.split(u',')]
|
tag_list = [tag_name.strip() for tag_name in tags.split(u',')]
|
||||||
tag_urls = [utils.generate_url(tag_name) for tag_name in tags.split(u',')]
|
tag_urls = [utils.generate_url(tag_name) for tag_name in tags.split(u',')]
|
||||||
db_tags = Session.query(Tag).filter(Tag.url.in_(tag_urls)).all()
|
db_tags = Session.query(Tag).filter(Tag.url.in_(tag_urls)).all()
|
||||||
@ -89,7 +90,7 @@ class PostController(BaseController):
|
|||||||
post.tags.append(Tag(name=tag, url=utils.generate_url(tag)))
|
post.tags.append(Tag(name=tag, url=utils.generate_url(tag)))
|
||||||
Session.add(post)
|
Session.add(post)
|
||||||
Session.commit()
|
Session.commit()
|
||||||
if c.form_values[u'action'] == u'Save Draft':
|
if c.form_values[u'post-action'] == u'Save Draft':
|
||||||
h.redirect_to(h.url_for(controller=u'post', action=u'draft'))
|
h.redirect_to(h.url_for(controller=u'post', action=u'draft'))
|
||||||
else:
|
else:
|
||||||
h.redirect_to(h.url_for_post(post))
|
h.redirect_to(h.url_for_post(post))
|
||||||
|
@ -404,6 +404,12 @@ fieldset {
|
|||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-hint {
|
||||||
|
color: #454545;
|
||||||
|
font-size: 0.8em;
|
||||||
|
margin-top: 0.2em;
|
||||||
|
}
|
||||||
|
|
||||||
#register-now {
|
#register-now {
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,14 @@
|
|||||||
<div class="form-item">
|
<div class="form-item">
|
||||||
<label for="post-authored">Authored:</label>
|
<label for="post-authored">Authored:</label>
|
||||||
<input type="text" name="post-authored" id="post-authored" class="form-text" value="${c.post.created.strftime('%Y/%m/%d %H:%M:%S')}" />
|
<input type="text" name="post-authored" id="post-authored" class="form-text" value="${c.post.created.strftime('%Y/%m/%d %H:%M:%S')}" />
|
||||||
|
<div class="form-hint">Date format is YYYY/MM/DD HH:MM:SS.</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-item">
|
<div class="form-item">
|
||||||
% if c.post.status == u'published':
|
% if c.post.status == u'published':
|
||||||
<input type="submit" name="action" value="Save" class="form-button"/>
|
<input type="submit" name="post-action" value="Save" class="form-button"/>
|
||||||
% else:
|
% else:
|
||||||
<input type="submit" name="action" value="Save Draft" class="form-button"/>
|
<input type="submit" name="post-action" value="Save Draft" class="form-button"/>
|
||||||
<input type="submit" name="action" value="Save & Publish" class="form-button"/>
|
<input type="submit" name="post-action" value="Save & Publish" class="form-button"/>
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -20,10 +20,11 @@
|
|||||||
<div class="form-item">
|
<div class="form-item">
|
||||||
<label for="post-authored">Authored:</label>
|
<label for="post-authored">Authored:</label>
|
||||||
<input type="text" name="post-authored" id="post-authored" class="form-text" value="${c.now.strftime('%Y/%m/%d %H:%M:%S')}" />
|
<input type="text" name="post-authored" id="post-authored" class="form-text" value="${c.now.strftime('%Y/%m/%d %H:%M:%S')}" />
|
||||||
|
<div class="form-hint">Date format is YYYY/MM/DD HH:MM:SS.</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-item">
|
<div class="form-item">
|
||||||
<input type="submit" name="action" value="Save Draft" class="form-button"/>
|
<input type="submit" name="post-action" value="Save Draft" class="form-button"/>
|
||||||
<input type="submit" name="action" value="Save & Publish" class="form-button"/>
|
<input type="submit" name="post-action" value="Save & Publish" class="form-button"/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
Reference in New Issue
Block a user