diff --git a/boxoffice/mailclient.py b/boxoffice/mailclient.py index d42984be..cfc70f39 100644 --- a/boxoffice/mailclient.py +++ b/boxoffice/mailclient.py @@ -86,7 +86,7 @@ def send_ticket_assignment_mail(line_item_id): order = line_item.order subject = order.item_collection.title + ": Here's your ticket" msg = Message(subject=subject, recipients=[line_item.current_assignee.email], bcc=[order.buyer_email]) - html = email_transform(render_template('ticket_assignment_mail.html', order=order, org=order.organization, line_item=line_item, base_url=app.config['BASE_URL'])) + html = email_transform(render_template('ticket_assignment_mail.html', org=order.organization, item_collection=order.item_collection, order=order, line_item=line_item, base_url=app.config['BASE_URL'])) msg.html = html msg.body = html2text(html) mail.send(msg) diff --git a/boxoffice/models/item.py b/boxoffice/models/item.py index aa5a9197..360b71b1 100644 --- a/boxoffice/models/item.py +++ b/boxoffice/models/item.py @@ -17,6 +17,7 @@ class Item(BaseScopedNameMixin, db.Model): __table_args__ = (db.UniqueConstraint('item_collection_id', 'name'),) description = MarkdownColumn('description', default=u'', nullable=False) + details = db.Column(JsonDict, server_default='{}', nullable=False) seq = db.Column(db.Integer, nullable=False) item_collection_id = db.Column(None, db.ForeignKey('item_collection.id'), nullable=False) diff --git a/boxoffice/models/item_collection.py b/boxoffice/models/item_collection.py index 2c2b127b..76d3deb3 100644 --- a/boxoffice/models/item_collection.py +++ b/boxoffice/models/item_collection.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from ..models import db, BaseScopedNameMixin, Organization, MarkdownColumn +from ..models import db, JsonDict, BaseScopedNameMixin, Organization, MarkdownColumn __all__ = ['ItemCollection'] @@ -14,6 +14,7 @@ class ItemCollection(BaseScopedNameMixin, db.Model): __table_args__ = (db.UniqueConstraint('organization_id', 'name'),) description = MarkdownColumn('description', default=u'', nullable=False) + details = db.Column(JsonDict, server_default='{}', nullable=False) organization_id = db.Column(db.Integer, db.ForeignKey('organization.id'), nullable=False) organization = db.relationship(Organization, backref=db.backref('item_collections', cascade='all, delete-orphan')) diff --git a/boxoffice/siteadmin.py b/boxoffice/siteadmin.py index 515ff959..031b4538 100644 --- a/boxoffice/siteadmin.py +++ b/boxoffice/siteadmin.py @@ -23,6 +23,7 @@ class ItemCollectionModelView(SiteAdminModelView): column_filters = ['organization'] column_list = ('id', 'title') form_excluded_columns = ['parent', 'items', 'orders', 'categories', 'created_at', 'updated_at'] + form_overrides = dict(details=JSONField) class CategoryModelView(SiteAdminModelView): @@ -40,7 +41,7 @@ class ItemModelView(SiteAdminModelView): column_searchable_list = ['title'] column_list = ('id', 'title') form_excluded_columns = ['parent', 'line_items', 'created_at', 'updated_at'] - form_overrides = dict(assignee_details=JSONField) + form_overrides = dict(assignee_details=JSONField, details=JSONField) class PriceModelView(SiteAdminModelView): diff --git a/boxoffice/templates/boxoffice.html b/boxoffice/templates/boxoffice.html index e0cd9c0e..052d96c3 100644 --- a/boxoffice/templates/boxoffice.html +++ b/boxoffice/templates/boxoffice.html @@ -172,31 +172,52 @@
Thank you for your order!
-We’ve mailed you the cash receipt.
- - +Thank you for your order! We’ve mailed you the cash receipt.
+Register
+Almost done! We need a few more details before we can print your badge.
+ +{{ eventTitle }}
++ {{#if getConfirmedTicket(order.line_items).item_details }} + {{ getConfirmedTicket(order.line_items).item_details.date }} + | {{ getConfirmedTicket(order.line_items).item_details.time }} + {{/if}} +
+Name
+|
+Company
+ + {{#if getConfirmedTicket(order.line_items).item_details }} +Venue
+{{ getConfirmedTicket(order.line_items).item_details.venue }}
+ {{/if}} +Ticket
+{{ getConfirmedTicket(order.line_items).item_title }}
+Hello {{ order.buyer_fullname }},
-Thanks for your interest in {{ order.item_collection.title }}.
+Thanks for your interest in {{ order.item_collection.title }}. Please take a moment to tell us who will be attending on your ticket(s).
- +Hello {{ line_item.current_assignee.fullname }},
-
- {{ line_item.item.title }} -Receipt No: {{order.invoice_no}} - |
-
-
- {{ line_item.current_assignee.fullname }} - {%- if line_item.current_assignee.details.company -%}{{ line_item.current_assignee.details.company }} {%- endif %} - {%- if line_item.current_assignee.details.twitter -%}@{{ line_item.current_assignee.details.twitter | replace("@", "") }} {%- endif %} - |
-
{{ item_collection.title }}
++ {%- if line_item.item.details.date -%} + {{ line_item.item.details.date }} + {%- endif %} + {%- if line_item.item.details.time -%} + | {{ line_item.item.details.time }} + {%- endif %} +
+Ticket
+{{ line_item.item.title }}
+Name
+{{ line_item.current_assignee.fullname }}
+ {%- if line_item.current_assignee.details.company -%} +Company
+{{ line_item.current_assignee.details.company }}
+ {%- endif %} + {%- if line_item.current_assignee.details.twitter -%} +@{{ line_item.current_assignee.details.twitter | replace("@", "") }}
+ {%- endif %} + {%- if line_item.item.details.venue -%} +Venue
+ {%- if line_item.item.details.venue_url -%} +{{ line_item.item.details.venue }}
+ {%- else -%} +{{ line_item.item.details.venue }}
+ {%- endif %} + {%- endif %} +Receipt No: {{ order.invoice_no }}
++ {%- if item_collection.details.twitter -%} + @{{ item_collection.details.twitter | replace("@", "") }} + {%- endif %} + {%- if item_collection.details.website -%} + | {{ item_collection.details.website }} + {%- endif %} +
+Thank you,
{{ org.title }}
diff --git a/boxoffice/views/item_collection.py b/boxoffice/views/item_collection.py index 847d9c23..13b8037f 100644 --- a/boxoffice/views/item_collection.py +++ b/boxoffice/views/item_collection.py @@ -15,6 +15,7 @@ def jsonify_item(item): 'title': item.title, 'id': item.id, 'description': item.description.text, + 'details': item.details, 'quantity_available': item.quantity_available, 'is_available': item.is_available, 'quantity_total': item.quantity_total, @@ -66,4 +67,4 @@ def item_collection(item_collection): category_json = jsonify_category(category) if category_json: categories_json.append(category_json) - return jsonify(html=render_template('boxoffice.html'), categories=categories_json, refund_policy=item_collection.organization.details.get('refund_policy', '')) + return jsonify(html=render_template('boxoffice.html'), categories=categories_json, eventTitle=item_collection.title, eventDetails=item_collection.details, refund_policy=item_collection.organization.details.get('refund_policy', '')) diff --git a/migrations/versions/3d55fce529de_add_details_to_item_itemcollection.py b/migrations/versions/3d55fce529de_add_details_to_item_itemcollection.py new file mode 100644 index 00000000..c3d4b2ce --- /dev/null +++ b/migrations/versions/3d55fce529de_add_details_to_item_itemcollection.py @@ -0,0 +1,25 @@ +"""add details to item itemcollection + +Revision ID: 3d55fce529de +Revises: 36f458047cfd +Create Date: 2017-05-31 15:31:09.140120 + +""" + +# revision identifiers, used by Alembic. +revision = '3d55fce529de' +down_revision = '36f458047cfd' + +from alembic import op +import sqlalchemy as sa +from coaster import sqlalchemy + + +def upgrade(): + op.add_column('item', sa.Column('details', sqlalchemy.JsonDict(), nullable=False, server_default='{}')) + op.add_column('item_collection', sa.Column('details', sqlalchemy.JsonDict(), nullable=False, server_default='{}')) + + +def downgrade(): + op.drop_column('item_collection', 'details') + op.drop_column('item', 'details') diff --git a/tests/fixtures.py b/tests/fixtures.py index 96c793d6..1750f357 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -21,7 +21,7 @@ def init_data(): db.session.add(rootconf) db.session.commit() - rc2016 = ItemCollection(title='2016', organization=rootconf) + rc2016 = ItemCollection(title='2016', organization=rootconf, details={'website': 'www.rootconf.in', 'logo': 'https://imgee.s3.amazonaws.com/imgee/769dc463009d4cf09be7352c8c7b3628.png', 'twitter': 'rootconf', 'banner_color': '#453750', 'font_color': '#fff'}) db.session.add(rc2016) db.session.commit() @@ -35,7 +35,7 @@ def init_data(): # import IPython; IPython.embed() with db.session.no_autoflush: - conf_ticket = Item(title='Conference ticket', description='14 - 15 April 2016
MLR Convention Center, JP Nagar
This ticket gets you access to rootconf conference on 14th and 15th April 2016.
', item_collection=rc2016, category=Category.query.filter_by(name='conference').first(), quantity_total=1000) + conf_ticket = Item(title='Conference ticket', description='14 - 15 April 2016
MLR Convention Center, JP Nagar
This ticket gets you access to rootconf conference on 14th and 15th April 2016.
', details={'date': '14-15 April 2016', 'venue': 'MLR Convention Centre, JP Nagar, Bangalore', 'venue_url': 'http://goo.gl/maps/pTOsq', 'time': '8:40 am'}, item_collection=rc2016, category=Category.query.filter_by(name='conference').first(), quantity_total=1000) rc2016.items.append(conf_ticket) db.session.commit() diff --git a/tests/test_item_collection.py b/tests/test_item_collection.py index 59771f6c..67466999 100644 --- a/tests/test_item_collection.py +++ b/tests/test_item_collection.py @@ -7,7 +7,7 @@ class TestItemCollectionAPI(unittest.TestCase): - expected_keys = ['categories', 'html', 'refund_policy'] + expected_keys = ['categories', 'html', 'eventTitle', 'eventDetails', 'refund_policy'] expected_categories_names = ['conference', 'workshop', 'merchandise'] expected_data = { "conference": { diff --git a/website.py b/website.py new file mode 100644 index 00000000..1103b7b9 --- /dev/null +++ b/website.py @@ -0,0 +1,5 @@ +import sys +import os.path +sys.path.insert(0, os.path.dirname(__file__)) + +from boxoffice import app as application