Skip to content

Commit

Permalink
Merge pull request #28 from hasgeek/arvind-features
Browse files Browse the repository at this point in the history
Added confirm button, youtube link
  • Loading branch information
jace committed Oct 8, 2012
2 parents 982f43c + d63b31d commit a545c40
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
7 changes: 7 additions & 0 deletions forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,10 @@ class ConfirmDeleteForm(wtf.Form):
# The labels on these widgets are not used. See delete.html.
delete = wtf.SubmitField(u"Delete")
cancel = wtf.SubmitField(u"Cancel")


class ConfirmSessionForm(wtf.Form):
"""
Dummy form for CSRF
"""
pass
4 changes: 4 additions & 0 deletions static/js/libs/jquery-1.7.1.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion static/js/packed.js

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions templates/proposal.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ <h1>{{ proposal.title }}</h1>
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="hasgeek">Tweet</a>
<g:plusone size="medium"></g:plusone>
<iframe class="facebooklike" src="http://www.facebook.com/plugins/like.php?app_id=114496105304651&amp;href={{ request.url }}&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=recommend&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>
{% if 'siteadmin' in g.lastuserinfo.permissions %}
<form method="POST" action="{{ url_for('confirmsession', name=space.name, slug=proposal.urlname) }}" style="float: left">
{{ confirmform.hidden_tag() }}
{% if proposal.confirmed -%}
<button type="submit">Cancel Session</button>
{% else %}
<button type="submit">Confirm Session</button>
{% endif -%}
</form>
{% endif %}
</div>
</div>
<div class="section bar">
Expand All @@ -85,7 +95,7 @@ <h1>{{ proposal.title }}</h1>
If you’d like to speak, leave a comment.</em>
</p>
{%- endif -%}

<h2>Objective</h2>
{{ proposal.objective_html|safe }}
<h2>Description</h2>
Expand All @@ -110,7 +120,7 @@ <h2 id="slides">Slides</h2>
{% endif %}
{% if proposal.links %}
<h2 id="links">Links</h2>
<ul>
<ul id="links-list">
{% for link in links -%}
<li>{{ link }}</li>
{% endfor %}
Expand Down Expand Up @@ -170,6 +180,9 @@ <h2 id="comments">Comments</h2>
{%- if proposal.slides %}
$("#slides-link").oembed();
{%- endif %}
{%- if proposal.links %}
$("#links-list").oembed();
{%- endif %}
});
</script>
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
Expand Down
28 changes: 24 additions & 4 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from app import app
from models import *
from forms import ProposalSpaceForm, SectionForm, ProposalForm, CommentForm, DeleteCommentForm, ConfirmDeleteForm
from forms import (ProposalSpaceForm, SectionForm, ProposalForm, CommentForm, DeleteCommentForm,
ConfirmDeleteForm, ConfirmSessionForm)
from utils import makename

lastuser = LastUser(app)
Expand All @@ -25,7 +26,6 @@
# From http://daringfireball.net/2010/07/improved_regex_for_matching_urls
url_re = re.compile(ur'''(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))''')


# --- Routes ------------------------------------------------------------------


Expand All @@ -43,7 +43,7 @@ def favicon():
@app.route('/login')
@lastuser.login_handler
def login():
return {'scope': 'id email'}
return {'scope': 'id email organizations'}


@app.route('/logout')
Expand Down Expand Up @@ -261,6 +261,25 @@ def editsession(name, slug):
'This form uses <a href="http://daringfireball.net/projects/markdown/">Markdown</a> for formatting.'))


@app.route('/<name>/<slug>/confirm', methods=['POST'])
@lastuser.requires_permission('siteadmin')
def confirmsession(name, slug):
ProposalSpace.query.filter_by(name=name).first_or_404()
proposal_id = int(slug.split('-')[0])
proposal = Proposal.query.get(proposal_id)
if not proposal:
abort(404)
form = ConfirmSessionForm()
if form.validate_on_submit():
proposal.confirmed = not proposal.confirmed
db.session.commit()
if proposal.confirmed:
flash("This proposal has been confirmed.", 'success')
else:
flash("This session has been cancelled.", 'success')
return redirect(url_for('viewsession', name=name, slug=slug))


@app.route('/<name>/<slug>/delete', methods=['GET', 'POST'])
@lastuser.requires_login
def deletesession(name, slug):
Expand Down Expand Up @@ -369,10 +388,11 @@ def viewsession(name, slug):
flash("No such comment.", "error")
return redirect(url_for('viewsession', name=space.name, slug=proposal.urlname), code=303)
links = [Markup(url_re.sub(urllink, unicode(escape(l)))) for l in proposal.links.replace('\r\n', '\n').split('\n') if l]
confirmform = ConfirmSessionForm()
return render_template('proposal.html', space=space, proposal=proposal,
comments=comments, commentform=commentform, delcommentform=delcommentform,
breadcrumbs=[(url_for('viewspace', name=space.name), space.title)],
links=links)
links=links, confirmform=confirmform)


# FIXME: This voting method uses GET but makes db changes. Not correct. Should be POST
Expand Down
2 changes: 1 addition & 1 deletion website.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# --- Assets ------------------------------------------------------------------

assets = Environment(app)
js = Bundle('js/libs/jquery-1.5.1.min.js',
js = Bundle('js/libs/jquery-1.7.1.min.js',
'js/libs/jquery.form.js',
'js/libs/jquery.oembed.js',
'js/libs/jquery.tablesorter.min.js',
Expand Down

0 comments on commit a545c40

Please sign in to comment.