Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions broadgauge/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ class ContactForm(BaseForm):
subject = StringField('Subject', [validators.Required()])
message = TextAreaField('Your Question', [validators.Required()])

class SponsorForm(BaseForm):
email = StringField('E-mail Address', [validators.Required(), validators.Email()])
to = StringField('Workshop owner', [validators.Required(), validators.Email()])
subject = StringField('Subject', [validators.Required()])
message = TextAreaField('Message. Type of sponsorship: food, venue, money...', [validators.Required()])

class AdminSendmailForm(BaseForm):
to = SelectField(
Expand Down
3 changes: 3 additions & 0 deletions broadgauge/templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ <h3 class="workshop-title"><a href="/workshops/{{ workshop.id }}">{{ workshop.ti
{% elif workshop.status == 'confirmed' %}
<div class="workshop-label"><span style="color: #444; border: 1px solid #ccd; border-radius: 5px; padding: 2px; background: #dde;">Confirmed</span></div>
{% endif %}
{% if not(org.is_member(user)) %}
<a href="/workshops/{{workshop.id}}/sponsor" class="btn btn-primary btn-medium">I want to sponsor</a>
{% endif %}
</div>
{% endmacro %}

Expand Down
6 changes: 3 additions & 3 deletions broadgauge/templates/workshops/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ <h1>Workshops</h1>
<div class="row">
<div class="col-md-4">
<h2>Upcoming</h2>
{{ workshop_list(pending_workshops) }}
{{ workshop_list(pending_workshops, user) }}
</div>
<div class="col-md-4">
<h2>Confirmed</h2>
{{ workshop_list(upcoming_workshops) }}
{{ workshop_list(upcoming_workshops, user) }}
</div>
<div class="col-md-4">
<h2>Completed</h2>
{{ workshop_list(completed_workshops) }}
{{ workshop_list(completed_workshops, user) }}
</div>
</div>
{% if user and user.is_admin() %}
Expand Down
17 changes: 17 additions & 0 deletions broadgauge/templates/workshops/sponsor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% from "forms.html" import render_field %}
{% extends "base.html" %}
{% block content %}
<h1>Sponsor <a href="/workshops/{{workshop.id}}">{{workshop.title}}</a></h1>

<div class="row">
<div class="col-md-6 col-sm-12">
<form role="form" method="POST">
{{ render_field(form.to, disabled=true) }}
{{ render_field(form.email, disabled=true) }}
{{ render_field(form.subject) }}
{{ render_field(form.message, rows=5) }}
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
{% endblock %}
8 changes: 8 additions & 0 deletions broadgauge/templates/workshops/workshop_sponsor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block content %}
<h1>Sponsor</h1>

<div class="row">
Form
</div>
{% endblock %}
46 changes: 46 additions & 0 deletions broadgauge/views/workshops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import web
from ..models import User, Workshop, Organization
from ..sendmail import sendmail_with_template
from ..template import render_template
from ..flash import flash
from .. import account
Expand All @@ -13,6 +14,7 @@
urls = (
"/workshops", "workshop_list",
"/workshops/(\d+)", "workshop_view",
"/workshops/(\d+)/sponsor", "workshop_sponsor",
"/workshops/(\d+)/edit", "workshop_edit",
"/workshops/(\d+)/set-trainer", "workshop_set_trainer",
)
Expand Down Expand Up @@ -163,6 +165,50 @@ def POST_unhide_workshop(self, workshop, i):
raise web.forbidden(render_template("permission_denied.html"))


class workshop_sponsor:
def GET(self, workshop_id):
#Getting the workshop and organization for that workshop
workshop = get_workshop(id=workshop_id)
org = workshop.get_org()

form = forms.SponsorForm()
user = account.get_current_user()
if user:
form.email.data = user.email

#Fetching the email of the admin user for the organisation
members = org.get_members()
email = ''
for member, role in members:
if member.is_admin:
email = member['email']
break
if email != '':
form.to.data = email
form.subject.data = "Sponsorship for " + workshop.title
return render_template("workshops/sponsor.html", workshop=workshop,
org=org, form=form)
else:
flash("There is no valid email for this organization.")
raise web.seeother("/workshops")

#Sending email to admin
def POST(self, workshop_id):
i = web.input()
form = forms.SponsorForm(i)
if form.validate():
sendmail_with_template("emails/contact.html",
to=form.to.data,
subject=form.subject.data,
message=form.message.data,
headers={'Reply-To': form.email.data})
return render_template("message.html",
title="Sent!",
message="Thank you for sponsoring us. We'll get back to you shortly.")
else:
return render_template("workshops/sponsor.html", form=form)


class workshop_edit:
def GET(self, workshop_id):
workshop = get_workshop(id=workshop_id)
Expand Down