Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename variable and function names and add functional tests for booking workflows #131

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cache:
- $HOME/.cache/pip
before_script:
- sudo -- sh -c "echo '127.0.0.1 boxoffice.travis.dev' >> /etc/hosts"
- sudo -- sh -c "echo '127.0.0.1 testing.travis.dev' >> /etc/hosts"
- psql -c 'create database boxoffice_testing;' -U postgres
install:
- pip install -U pip wheel
Expand All @@ -15,7 +16,11 @@ install:
script:
- nosetests -v tests
- nohup python runtestserver.py &
- sleep 10
- cd tests
- python -m SimpleHTTPServer 8000 &
- cd ..
- sleep 30
- casperjs test tests
addons:
postgresql: "9.4"
services:
Expand Down
32 changes: 16 additions & 16 deletions boxoffice/static/js/dist/bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions boxoffice/static/js/models/admin_order.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {fetch, post} from './util.js';
import {Fetch, Post} from './util.js';
import {IndexModel} from './index.js';

export const OrderModel = {
fetch: fetch,
post: post,
fetch: Fetch,
post: Post,
urlFor: function(action, config){
let urls = {
'index': {
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.ic_id + '/orders',
'relative_path': 'ic/' + config.ic_id + '/orders',
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.icId + '/orders',
'relativePath': 'ic/' + config.icId + '/orders',
'method': 'GET'
},
'view': {
'path': IndexModel.urlFor('index')['path'] + 'order/' + config.order_id,
'path': IndexModel.urlFor('index')['path'] + 'order/' + config.orderId,
'method': 'GET'
}
}
Expand Down
12 changes: 6 additions & 6 deletions boxoffice/static/js/models/admin_report.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {fetch, post} from './util.js';
import {Fetch, Post} from './util.js';
import {IndexModel} from './index.js';

export const ReportModel = {
fetch: fetch,
post: post,
fetch: Fetch,
post: Post,
urlFor: function(action, config){
let urls = {
'index': {
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.ic_id + '/reports',
'relative_path': 'ic/' + config.ic_id + '/reports',
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.icId + '/reports',
'relativePath': 'ic/' + config.icId + '/reports',
'method': 'GET'
},
'tickets': {
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.ic_id + '/reports/tickets.csv',
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.icId + '/reports/tickets.csv',
'method': 'GET'
}
}
Expand Down
6 changes: 3 additions & 3 deletions boxoffice/static/js/models/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {fetch} from './util.js';
import {Fetch} from './util.js';

export const IndexModel = {
fetch: fetch,
fetch: Fetch,
urlFor: function(action){
let urls = {
'index': {
'path': Backbone.history.root,
'relative_path': '/',
'relativePath': '/',
'method': 'GET'
}
}
Expand Down
18 changes: 9 additions & 9 deletions boxoffice/static/js/models/item_collection.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Util, fetch} from './util.js';
import {Util, Fetch} from './util.js';
import {IndexModel} from './index.js';


export const ItemCollectionModel = {
fetch: fetch,
fetch: Fetch,
urlFor: function(action, config){
let urls = {
'index': {
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.ic_id,
'relative_path': 'ic/' + config.ic_id,
'path': IndexModel.urlFor('index')['path'] + 'ic/' + config.icId,
'relativePath': 'ic/' + config.icId,
'method': 'GET'
}
}
Expand All @@ -25,11 +25,11 @@ export const ItemCollectionModel = {
return {
title: data.title,
items: this.formatItems(data.items),
date_item_counts: data.date_item_counts,
date_sales: data.date_sales,
net_sales: Util.formatToIndianRupee(data.net_sales),
sales_delta: data.sales_delta,
today_sales: Util.formatToIndianRupee(data.today_sales)
dateItemCounts: data.date_item_counts,
dateSales: data.date_sales,
netSales: Util.formatToIndianRupee(data.net_sales),
salesDelta: data.sales_delta,
todaySales: Util.formatToIndianRupee(data.today_sales)
}
}
}
8 changes: 4 additions & 4 deletions boxoffice/static/js/models/org.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {fetch} from './util.js';
import {Fetch} from './util.js';
import {IndexModel} from './index.js';

export const OrgModel = {
fetch: fetch,
fetch: Fetch,
urlFor: function(action, config){
let urls = {
'index': {
'path': IndexModel.urlFor('index')['path'] + 'o/' + config.org_name,
'relative_path': 'o/' + config.org_name,
'path': IndexModel.urlFor('index')['path'] + 'o/' + config.orgName,
'relativePath': 'o/' + config.orgName,
'method': 'GET'
}
}
Expand Down
18 changes: 9 additions & 9 deletions boxoffice/static/js/models/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ import {ReportModel} from './admin_report.js';

export const SideBarModel = {
getItems: function(config) {
let sidebar_items = [];
if (config.org_name && config.ic_id) {
sidebar_items = [
let sidebarItems = [];
if (config.orgName && config.icId) {
sidebarItems = [
{
url: IndexModel.urlFor('index')['relative_path'],
url: IndexModel.urlFor('index')['relativePath'],
title: 'Home',
icon: 'fa-home',
view: 'home'
},
{
url: OrgModel.urlFor('index', {org_name: config.org_name})['relative_path'],
url: OrgModel.urlFor('index', {orgName: config.orgName})['relativePath'],
title: 'Organization',
icon: 'fa-sitemap',
view: 'org'
},
{
url: ItemCollectionModel.urlFor('index', {ic_id: config.ic_id})['relative_path'],
url: ItemCollectionModel.urlFor('index', {icId: config.icId})['relativePath'],
title: 'Dashboard',
icon: 'fa-dashboard',
view: 'dashboard'
},
{
url: OrderModel.urlFor('index', {ic_id: config.ic_id})['relative_path'],
url: OrderModel.urlFor('index', {icId: config.icId})['relativePath'],
title: 'Orders',
icon: 'fa-shopping-cart',
view: 'orders'
},
{
url: ReportModel.urlFor('index', {ic_id: config.ic_id})['relative_path'],
url: ReportModel.urlFor('index', {icId: config.icId})['relativePath'],
title: 'Reports',
icon: 'fa-file-excel-o',
view: 'reports'
}
]
}
return sidebar_items;
return sidebarItems;
}
};
6 changes: 3 additions & 3 deletions boxoffice/static/js/models/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ export const Util = {
}
}

export const fetch = function(config){
export const Fetch = function(config){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this capitalized? Capitals are usually reserved for constructors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or for container objects.

return $.ajax({
url: config.url,
dataType: 'json'
});
}

export const post = function(config){
export const Post = function(config){
return $.ajax({
url: config.url,
type: 'POST',
dataType: 'json'
});
}

export const scrollToElement = function(element, speed=500) {
export const ScrollToElement = function(element, speed=500) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. This should be scrollToElement.

$('html,body').animate({
scrollTop: $(element).offset().top
}, speed);
Expand Down
20 changes: 10 additions & 10 deletions boxoffice/static/js/templates/admin_order.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const OrderTemplate = `
<td><p class="table-content">{{ buyer_fullname }}</p></td>
<td><p class="table-content">{{ buyer_email }}</p></td>
<td><p class="table-content">{{ buyer_phone }}</p></td>
<td><p class="table-content">{{currency}}{{ amount }}</p></td>
<td><p class="table-content">{{ formatCurrency(amount) }}</p></td>
<td><p class="table-content">{{ order_date }}</p></td>
<td><p class="table-content">{{ id }}</p></td>
<td>
Expand All @@ -59,12 +59,12 @@ export const OrderTemplate = `
</p>
</td>
</tr>
{{#show_order}}
{{#showOrder}}
<div class="order-slider" intro-outro='fly:{x:200,y:0,duration:200}'>
<button on-click="hideOrder" class="close-button"><i class="fa fa-close"></i></button>
<p class="order-title">Order Invoice No: {{invoice_no}}</p>
<p class="order-title">Order Invoice No: {{ invoice_no }}</p>
<div class="line-items-wrapper">
{{#line_items:line_item}}
{{#lineItems:lineItem}}
<div class="ticket col-sm-6 col-xs-12" id="item-{{ @index }}">
<div class="heading">
<div class="ticket-type">
Expand All @@ -74,9 +74,9 @@ export const OrderTemplate = `
<div class="content">
<div class="content-box">
<p><span class="italic-title">id:</span> {{ id }}</p>
<p><span class="italic-title">Base amount:</span> {{ currency }}{{ base_amount }}</p>
<p><span class="italic-title">Discounted amount:</span> {{ currency }}{{ discounted_amount }}</p>
<p><span class="italic-title">Final amount:</span> {{ currency }}{{ final_amount }}</p>
<p><span class="italic-title">Base amount:</span> {{ formatCurrency(base_amount) }}</p>
<p><span class="italic-title">Discounted amount:</span> {{ formatCurrency(discounted_amount) }}</p>
<p><span class="italic-title">Final amount:</span> {{ formatCurrency(final_amount) }}</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't base_amount, discounted_amount and final_amount also be in camelCase?

{{#discount_policy}}<p><span class="italic-title">Discount policy:</span> <span class="line-item-discount">{{ discount_policy }}</span>{{/}}
{{#discount_coupon}}<p><span class="italic-title">Discount coupon:</span> <span class="line-item-discount">{{ discount_coupon }}</span>{{/}}
{{#cancelled_at}}<p><b><span class="italic-title cancelled">Cancelled at: {{ cancelled_at }}</span></b></p>{{/}}
Expand All @@ -96,15 +96,15 @@ export const OrderTemplate = `
Cancel {{#cancelling}}<i class="fa fa-spinner fa-spin"></i>{{/}}
</button>
</p>
<p class="error-msg left-aligned">{{cancel_error}}</p>
<p class="error-msg left-aligned">{{ cancelError }}</p>
{{/}}
</div>
</div>
</div>
{{/}}
{{/lineItems}}
</div>
</div>
{{/show_order}}
{{/showOrder}}
{{/orders}}
</tbody>
<tfoot>
Expand Down
5 changes: 2 additions & 3 deletions boxoffice/static/js/templates/admin_report.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ export const ReportTemplate = `
<form role="form" id="report-form">
<div class="group-select">
<p class="field-title filled">Report type</p>
<select name="type" value="{{report_type}}">
<select name="type" value="{{ reportType }}">
<option value="tickets">Tickets</option>
</select>
</div>
<div class="btn-wrapper">
<a href="{{reports_url()}}" download="{{reports_filename()}}" class="boxoffice-button boxoffice-button-action">Download</a>
<a href="{{ reportsUrl() }}" download="{{ reportsFilename() }}" class="boxoffice-button boxoffice-button-action">Download</a>
</div>
<p class="error-msg">{{download_report_error}}</p>
</form>
</div>
</div>
Expand Down
13 changes: 5 additions & 8 deletions boxoffice/static/js/templates/index.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ export const IndexTemplate = `
</div>
<div class="content">
<div class="content-box clearfix" intro='fly:{"x":20,"y":"0"}'>
<div class="org-logo"><img src="{{details['logo']}}"/></div>
<div class="org-logo"><img src="{{ details['logo'] }}"/></div>
<p class="section-title">Organization id</p>
<p class="section-content">{{id}}</p>
<p class="section-content">{{ id }}</p>
{{#details:k,v}}
{{#if k !== 'logo'}}
<p class="section-title">{{k}}</p>
<div class="section-content">{{{details[k]}}}</div>
<p class="section-title">{{ k }}</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is k?

<div class="section-content">{{{ details[k] }}}</div>
{{/if}}
{{/details}}
<p class="section-title">Contact email</p>
<div class="section-content">{{contact_email}}</div>
<div class="section-content">{{ contact_email }}</div>
<div class="btn-wrapper">
<a class="boxoffice-button boxoffice-button-action" href="javascript:void(0)" on-click="navigate">View item collections</a>
</div>
{{#infoMsg}}
<p class="info-msg">{{ infoMsg }} <i class="fa fa-check"></i></p>
{{/}}
</div>
</div>
{{/orgs}}
Expand Down
10 changes: 5 additions & 5 deletions boxoffice/static/js/templates/item_collection.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const ItemCollectionTemplate = `
</div>
<div class="card-right">
<h3 class="card-right-content">Net sales</h3>
<p class="card-right-content">{{net_sales}}</p>
<p class="card-right-content">{{ netSales }}</p>
</div>
</div>
</div>
Expand All @@ -62,24 +62,24 @@ export const ItemCollectionTemplate = `
</div>
<div class="card-right">
<h3 class="card-right-content">Today's sales</h3>
<p class="card-right-content">{{today_sales}}</p>
<p class="card-right-content">{{ todaySales }}</p>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="card clearfix">
<div class="card-left">
{{#if sales_delta > 0 }}
{{#if salesDelta > 0 }}
<p class="card-left-content"><i class="fa fa-arrow-up"></i></p>
{{elseif sales_delta < 0 }}
{{elseif salesDelta < 0 }}
<p class="card-left-content"><i class="fa fa-arrow-down"></i></p>
{{else}}
<p class="card-left-content"><i class="fa fa-minus"></i></p>
{{/if}}
</div>
<div class="card-right">
<h3 class="card-right-content">Sales since yesterday</h3>
<p class="card-right-content">{{sales_delta}}%</p>
<p class="card-right-content">{{ salesDelta }}%</p>
</div>
</div>
</div>
Expand Down
13 changes: 5 additions & 8 deletions boxoffice/static/js/templates/org.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const orgTemplate = `
<div class="container">
<div class="row">
<h1 class="header">{{ title }}</h1>
{{#item_collections:item_collection}}
{{#itemCollections:itemCollection}}
<div class="box col-sm-6 col-xs-12" id="item-collection-{{ @index }}">
<div class="heading">
{{#title}}
Expand All @@ -12,18 +12,15 @@ export const orgTemplate = `
<div class="content">
<div class="content-box clearfix" intro='fly:{"x":20,"y":"0"}'>
<p class="section-title">Item collection id</p>
<p class="section-content">{{id}}</p>
<p class="section-content">{{ id }}</p>
<p class="section-title">Item collection description</p>
<div class="section-content">{{{description_html}}}</div>
<div class="section-content">{{{ description_html }}}</div>
<div class="btn-wrapper">
<a class="boxoffice-button boxoffice-button-action" href="javascript:void(0)" on-click="navigate">View {{title}} dashboard</a>
<a class="boxoffice-button boxoffice-button-action" href="javascript:void(0)" on-click="navigate">View {{ title }} dashboard</a>
</div>
{{#infoMsg}}
<p class="info-msg">{{ infoMsg }} <i class="fa fa-check"></i></p>
{{/}}
</div>
</div>
{{/item_collections}}
{{/itemCollections}}
</div>
</div>
`
Loading