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 @@

{{title}}

{{elseif id === 'boxoffice-confirm' && id === activeTab}}
{{#section}} -

-

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.

+ +
+
+
+ {{#if eventDetails.logo}} + + {{/if}} +
+

{{ 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 }}

+
+
+
+
+

+ Fill attendee details +

{{/section}}
{{/if}} {{/}}
-{%endraw%} + +{%endraw%} diff --git a/boxoffice/templates/boxoffice.js b/boxoffice/templates/boxoffice.js index 9243db2a..e7203774 100644 --- a/boxoffice/templates/boxoffice.js +++ b/boxoffice/templates/boxoffice.js @@ -179,6 +179,7 @@ $(function() { 'discounted_amount': undefined, 'final_amount': undefined, 'item_description': item.description, + 'item_details': item.details, 'price_valid_upto': boxoffice.util.formatDate(item.price_valid_upto), 'has_higher_price': item.has_higher_price, 'discount_policies': item.discount_policies, @@ -227,12 +228,16 @@ $(function() { }, confirm: { id: 'boxoffice-confirm', - label: 'Confirm', + label: 'Register', complete: false, section: { - cashReceiptURL: '', - eventTitle: widgetConfig.paymentDesc, - eventHashtag: widgetConfig.event_hashtag, + eventTitle: data.eventTitle, + eventDetails: data.eventDetails, + getConfirmedTicket: function(line_items) { + return line_items.filter(function(line_item) { + return line_item.quantity > 0 + })[0]; + } } } }, diff --git a/boxoffice/templates/order_confirmation_mail.html b/boxoffice/templates/order_confirmation_mail.html index ab737680..8fc9347e 100644 --- a/boxoffice/templates/order_confirmation_mail.html +++ b/boxoffice/templates/order_confirmation_mail.html @@ -136,9 +136,9 @@

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).

-

See ticket

+

Fill attendee details

Cash Receipt

diff --git a/boxoffice/templates/ticket_assignment_mail.html b/boxoffice/templates/ticket_assignment_mail.html index 0c25c3d0..520814bc 100644 --- a/boxoffice/templates/ticket_assignment_mail.html +++ b/boxoffice/templates/ticket_assignment_mail.html @@ -2,7 +2,7 @@ - + {{ org.title }} @@ -105,25 +127,64 @@

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 -%}{%- endif %} -
+
+
+
+ {%- if item_collection.details.logo -%} + + {%- elif org.details.logo %} + + {%- 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 -%} +

Twitter

+ + {%- 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 -%} + + {%- endif %} + {%- if item_collection.details.website -%} +   |  {{ item_collection.details.website }} + {%- endif %} +

+
+
+

Edit details

-

Edit details

-
{{org.details.get('ticket_faq', '') | safe}}
+
{{ org.details.get('ticket_faq') | safe }}

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