Skip to content

Commit 30f97aa

Browse files
Merge developement and resolve conflicts
2 parents 39ebcac + be60472 commit 30f97aa

37 files changed

+1011
-514
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pycparser = "==2.14"
88
flask-script = "<2.1,>=2.0.5"
99
requests-oauthlib = ">=0.7.0,<1"
1010
icalendar = "<4,>=3.11"
11-
requests = {version = ">=2.12.4,<3", extras = ["security"]}
11+
requests = {version = ">=2.20.0,<3", extras = ["security"]}
1212
"psycopg2-binary" = "*"
1313
itsdangerous = "<0.30,>=0.24"
1414
humanize = ">=0.5.1,<0.6"

Pipfile.lock

Lines changed: 347 additions & 341 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ The tentative release policy, for now (since there is a lot of activity and a lo
268268
**Commits**
269269
* Write clear meaningful git commit messages (Do read http://chris.beams.io/posts/git-commit/)
270270
* Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. (More info at https://github.com/blog/1506-closing-issues-via-pull-requests )
271-
* When you make very very minor changes to a PR of yours (like for example fixing a failing travis build or some small style corrections or minor changes requested by reviewers) make sure you squash your commits afterward so that you don't have an absurd number of commits for a very small fix. (Learn how to squash at https://davidwalsh.name/squash-commits-git )
271+
* When you make very minor changes to a PR of yours (like for example fixing a failing travis build or some small style corrections or minor changes requested by reviewers) make sure you squash your commits afterward so that you don't have an absurd number of commits for a very small fix. (Learn how to squash at https://davidwalsh.name/squash-commits-git )
272272
* When you're submitting a PR for a UI-related issue, it would be really awesome if you add a screenshot of your change or a link to a deployment where it can be tested out along with your PR. It makes it very easy for the reviewers and you'll also get reviews quicker.
273273

274274
**Feature Requests and Bug Reports**

app/__init__.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from celery.signals import after_task_publish
2-
from logging.config import dictConfig
32
import logging
43
import os.path
54
from envparse import env
@@ -94,28 +93,8 @@ def create_app():
9493
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
9594
app.config['FILE_SYSTEM_STORAGE_FILE_VIEW'] = 'static'
9695

97-
app.logger = logging.getLogger(__name__)
98-
99-
dictConfig({
100-
'version': 1,
101-
'handlers': {
102-
'console': {
103-
'level': logging.WARN,
104-
'class': 'logging.StreamHandler',
105-
'stream': 'ext://sys.stdout'
106-
}
107-
},
108-
'loggers': {
109-
'': {
110-
'handlers': ['console'],
111-
'level': logging.WARN
112-
},
113-
'default': {
114-
'handlers': ['console'],
115-
'level': logging.INFO
116-
}
117-
}
118-
})
96+
app.logger.addHandler(logging.StreamHandler(sys.stdout))
97+
app.logger.setLevel(logging.ERROR)
11998

12099
# set up jwt
121100
app.config['JWT_AUTH_USERNAME_KEY'] = 'email'
@@ -148,6 +127,7 @@ def create_app():
148127
from app.api.users import user_misc_routes
149128
from app.api.orders import order_misc_routes
150129
from app.api.role_invites import role_invites_misc_routes
130+
from app.api.admin_translations import admin_blueprint
151131

152132
app.register_blueprint(api_v1)
153133
app.register_blueprint(event_copy)
@@ -161,6 +141,7 @@ def create_app():
161141
app.register_blueprint(attendee_misc_routes)
162142
app.register_blueprint(order_misc_routes)
163143
app.register_blueprint(role_invites_misc_routes)
144+
app.register_blueprint(admin_blueprint)
164145

165146
sa.orm.configure_mappers()
166147

app/api/admin_sales/fees.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ class Meta:
2222
name = fields.String()
2323
payment_currency = fields.String()
2424
fee_percentage = fields.Float(attribute='fee')
25+
maximum_fee = fields.Float(attribute='maximum_fee')
2526
revenue = fields.Method('calc_revenue')
2627
ticket_count = fields.Method('calc_ticket_count')
2728

2829
@staticmethod
2930
def calc_ticket_count(obj):
3031
"""Count all tickets in all orders of this event"""
31-
return sum([o.amount for o in obj.orders])
32+
return sum([o.tickets_count for o in obj.orders if o.status == 'completed'])
3233

3334
@staticmethod
3435
def calc_revenue(obj):

app/api/admin_translations.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from flask import send_file, Blueprint
2+
import shutil
3+
import uuid
4+
import tempfile
5+
import os
6+
7+
admin_blueprint = Blueprint('admin_blueprint', __name__, url_prefix='/admin/content/translations/all')
8+
temp_dir = tempfile.gettempdir()
9+
translations_dir = 'app/translations'
10+
11+
@admin_blueprint.route('/', methods=['GET'])
12+
def download_translations():
13+
"""Admin Translations Downloads"""
14+
uuid_literal = uuid.uuid4()
15+
zip_file = "translations{}".format(uuid_literal)
16+
zip_file_ext = zip_file+'.zip'
17+
shutil.make_archive(zip_file, "zip", translations_dir)
18+
shutil.move(zip_file_ext, temp_dir)
19+
path_to_zip = os.path.join(temp_dir, zip_file_ext)
20+
from .helpers.tasks import delete_translations
21+
delete_translations.apply_async(path_to_zip, countdown=600)
22+
return send_file(path_to_zip, mimetype='application/zip',
23+
as_attachment=True,
24+
attachment_filename='translations.zip')

app/api/data_layers/EventCopyLayer.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from flask_rest_jsonapi.data_layers.base import BaseDataLayer
44
from sqlalchemy.orm import make_transient
55

6-
from app.api.helpers.db import safe_query
6+
from app.api.helpers.db import safe_query, save_to_db
77
from app.api.helpers.files import create_save_resized_image
88
from app.models.custom_form import CustomForms
99
from app.models.discount_code import DiscountCode
@@ -45,8 +45,7 @@ def create_object(self, data, view_kwargs):
4545
make_transient(event)
4646
delattr(event, 'id')
4747
event.identifier = get_new_event_identifier()
48-
db.session.add(event)
49-
db.session.commit()
48+
save_to_db(event)
5049

5150
# Removes access_codes, order_tickets, ticket_tags for the new tickets created.
5251
for ticket in tickets:
@@ -55,17 +54,15 @@ def create_object(self, data, view_kwargs):
5554
make_transient(ticket)
5655
ticket.event_id = event.id
5756
delattr(ticket, 'id')
58-
db.session.add(ticket)
59-
db.session.commit()
57+
save_to_db(ticket)
6058

6159
for link in social_links:
6260
link_id = link.id
6361
db.session.expunge(link) # expunge the object from session
6462
make_transient(link)
6563
link.event_id = event.id
6664
delattr(link, 'id')
67-
db.session.add(link)
68-
db.session.commit()
65+
save_to_db(link)
6966

7067
for sponsor in sponsors:
7168
sponsor_id = sponsor.id
@@ -75,17 +72,15 @@ def create_object(self, data, view_kwargs):
7572
logo_url = create_save_resized_image(image_file=sponsor.logo_url, resize=False)
7673
delattr(sponsor, 'id')
7774
sponsor.logo_url = logo_url
78-
db.session.add(sponsor)
79-
db.session.commit()
75+
save_to_db(sponsor)
8076

8177
for location in microlocations:
8278
location_id = location.id
8379
db.session.expunge(location) # expunge the object from session
8480
make_transient(location)
8581
location.event_id = event.id
8682
delattr(location, 'id')
87-
db.session.add(location)
88-
db.session.commit()
83+
save_to_db(location)
8984

9085
# No sessions are copied for new tracks
9186
for track in tracks:
@@ -94,34 +89,30 @@ def create_object(self, data, view_kwargs):
9489
make_transient(track)
9590
track.event_id = event.id
9691
delattr(track, 'id')
97-
db.session.add(track)
98-
db.session.commit()
92+
save_to_db(track)
9993

10094
for call in speaker_calls:
10195
call_id = call.id
10296
db.session.expunge(call) # expunge the object from session
10397
make_transient(call)
10498
call.event_id = event.id
10599
delattr(call, 'id')
106-
db.session.add(call)
107-
db.session.commit()
100+
save_to_db(call)
108101

109102
for code in discount_codes:
110103
code_id = code.id
111104
db.session.expunge(code) # expunge the object from session
112105
make_transient(code)
113106
code.event_id = event.id
114107
delattr(code, 'id')
115-
db.session.add(code)
116-
db.session.commit()
108+
save_to_db(code)
117109

118110
for form in custom_forms:
119111
form_id = form.id
120112
db.session.expunge(form) # expunge the object from session
121113
make_transient(form)
122114
form.event_id = event.id
123115
delattr(form, 'id')
124-
db.session.add(form)
125-
db.session.commit()
116+
save_to_db(form)
126117

127118
return event

app/api/event_copy.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from flask import jsonify, Blueprint, abort, make_response
22
from sqlalchemy.orm import make_transient
33

4-
from app.api.helpers.db import safe_query
4+
from app.api.helpers.db import safe_query, save_to_db
55
from app.api.helpers.files import create_save_resized_image
66
from app.api.helpers.permission_manager import has_access
77
from app.models.custom_form import CustomForms
@@ -46,8 +46,7 @@ def create_event_copy(identifier):
4646
make_transient(event)
4747
delattr(event, 'id')
4848
event.identifier = get_new_event_identifier()
49-
db.session.add(event)
50-
db.session.commit()
49+
save_to_db(event)
5150

5251
# Removes access_codes, order_tickets, ticket_tags for the new tickets created.
5352
for ticket in tickets:
@@ -56,17 +55,15 @@ def create_event_copy(identifier):
5655
make_transient(ticket)
5756
ticket.event_id = event.id
5857
delattr(ticket, 'id')
59-
db.session.add(ticket)
60-
db.session.commit()
58+
save_to_db(ticket)
6159

6260
for link in social_links:
6361
link_id = link.id
6462
db.session.expunge(link) # expunge the object from session
6563
make_transient(link)
6664
link.event_id = event.id
6765
delattr(link, 'id')
68-
db.session.add(link)
69-
db.session.commit()
66+
save_to_db(link)
7067

7168
for sponsor in sponsors:
7269
sponsor_id = sponsor.id
@@ -76,17 +73,15 @@ def create_event_copy(identifier):
7673
logo_url = create_save_resized_image(image_file=sponsor.logo_url, resize=False)
7774
delattr(sponsor, 'id')
7875
sponsor.logo_url = logo_url
79-
db.session.add(sponsor)
80-
db.session.commit()
76+
save_to_db(sponsor)
8177

8278
for location in microlocations:
8379
location_id = location.id
8480
db.session.expunge(location) # expunge the object from session
8581
make_transient(location)
8682
location.event_id = event.id
8783
delattr(location, 'id')
88-
db.session.add(location)
89-
db.session.commit()
84+
save_to_db(location)
9085

9186
# No sessions are copied for new tracks
9287
for track in tracks:
@@ -95,43 +90,39 @@ def create_event_copy(identifier):
9590
make_transient(track)
9691
track.event_id = event.id
9792
delattr(track, 'id')
98-
db.session.add(track)
99-
db.session.commit()
93+
save_to_db(track)
10094

10195
for call in speaker_calls:
10296
call_id = call.id
10397
db.session.expunge(call) # expunge the object from session
10498
make_transient(call)
10599
call.event_id = event.id
106100
delattr(call, 'id')
107-
db.session.add(call)
108-
db.session.commit()
101+
save_to_db(call)
109102

110103
for code in discount_codes:
111104
code_id = code.id
112105
db.session.expunge(code) # expunge the object from session
113106
make_transient(code)
114107
code.event_id = event.id
115108
delattr(code, 'id')
116-
db.session.add(code)
117-
db.session.commit()
109+
save_to_db(code)
118110

119111
for form in custom_forms:
120112
form_id = form.id
121113
db.session.expunge(form) # expunge the object from session
122114
make_transient(form)
123115
form.event_id = event.id
124116
delattr(form, 'id')
125-
db.session.add(form)
126-
db.session.commit()
117+
save_to_db(form)
127118

128119
for user_role in user_event_roles:
120+
user_role_id = user_role.id
129121
db.session.expunge(user_role)
130122
make_transient(user_role)
131123
user_role.event_id = event.id
132124
delattr(user_role, 'id')
133-
db.session.add(user_role)
134-
db.session.commit()
125+
save_to_db(user_role)
135126

136127
return jsonify({
137128
'id': event.id,

0 commit comments

Comments
 (0)