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

Moving to Python3 #547

Merged
merged 10 commits into from
Feb 10, 2020
Merged
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- 2.7
- 3.7
before_script:
- sudo -- sh -c "echo '127.0.0.1 funnel.travis.local' >> /etc/hosts"
- psql -c 'create database funnel_testing;' -U postgres
Expand Down
1 change: 0 additions & 1 deletion funnel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from flask import Flask
from flask_flatpages import FlatPages
Expand Down
8 changes: 4 additions & 4 deletions funnel/extapi/boxoffice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from urlparse import urljoin
from urllib.parse import urljoin

from flask import current_app

Expand Down Expand Up @@ -35,7 +35,7 @@ def get_tickets(self, ic):
for order in self.get_orders(ic):
for line_item in order.get('line_items'):
if line_item.get('assignee'):
status = unicode(line_item.get('line_item_status'))
status = line_item.get('line_item_status')
tickets.append(
{
'fullname': line_item.get('assignee').get('fullname', ''),
Expand All @@ -47,11 +47,11 @@ def get_tickets(self, ic):
'company': line_item.get('assignee').get('company'),
'city': line_item.get('assignee').get('city', ''),
'job_title': line_item.get('assignee').get('jobtitle', ''),
'ticket_no': unicode(line_item.get('line_item_seq')),
'ticket_no': line_item.get('line_item_seq'),
'ticket_type': line_item.get('item', {}).get('title', '')[
:80
],
'order_no': unicode(order.get('invoice_no')),
'order_no': order.get('invoice_no'),
'status': status,
}
)
Expand Down
12 changes: 6 additions & 6 deletions funnel/extapi/explara.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExplaraAPI(object):

def __init__(self, access_token):
self.access_token = access_token
self.headers = {'Authorization': u'Bearer ' + self.access_token}
self.headers = {'Authorization': 'Bearer ' + self.access_token}
self.base_url = 'https://www.explara.com/api/e/{0}'

def url_for(self, endpoint):
Expand Down Expand Up @@ -53,7 +53,7 @@ def get_orders(self, explara_eventid):
ticket_orders.extend(attendee_response['attendee'])
# after the first batch, subsequent batches are dicts with batch no. as key.
elif isinstance(attendee_response.get('attendee'), dict):
ticket_orders.extend(attendee_response['attendee'].values())
ticket_orders.extend(list(attendee_response['attendee'].values()))
from_record = to_record
to_record += 50

Expand All @@ -65,11 +65,11 @@ def get_tickets(self, explara_eventid):
for attendee in order.get('attendee'):
# cancelled tickets are in this list too, hence the check
if attendee.get('status') == 'attending':
status = u'confirmed'
elif attendee.get('status') in [u'cancelled', u'lcancelled']:
status = u'cancelled'
status = 'confirmed'
elif attendee.get('status') in ['cancelled', 'lcancelled']:
status = 'cancelled'
else:
status = unicode(attendee.get('status'))
status = attendee.get('status')
# we sometimes get an empty array for details
details = attendee.get('details') or {}
tickets.append(
Expand Down
4 changes: 2 additions & 2 deletions funnel/forms/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LabelForm(forms.Form):
title = forms.StringField(
__("Label"),
validators=[
forms.validators.DataRequired(__(u"This can’t be empty")),
forms.validators.DataRequired(__("This can’t be empty")),
forms.validators.Length(max=250),
],
filters=[forms.filters.strip()],
Expand Down Expand Up @@ -42,7 +42,7 @@ class LabelOptionForm(forms.Form):
title = forms.StringField(
__("Option"),
validators=[
forms.validators.DataRequired(__(u"This can’t be empty")),
forms.validators.DataRequired(__("This can’t be empty")),
forms.validators.Length(max=250),
],
filters=[forms.filters.strip()],
Expand Down
2 changes: 1 addition & 1 deletion funnel/forms/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ParticipantForm(forms.Form):
widget=ListWidget(),
option_widget=CheckboxInput(),
get_label='title',
validators=[forms.validators.DataRequired(u"Select at least one event")],
validators=[forms.validators.DataRequired("Select at least one event")],
)


Expand Down
10 changes: 4 additions & 6 deletions funnel/forms/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class NewProfileForm(forms.Form):
profile = forms.RadioField(
__("Organization"),
validators=[forms.validators.DataRequired("Select an organization")],
description=__(
u"Select the organization you’d like to create a Talkfunnel for"
),
description=__("Select the organization you’d like to create a Talkfunnel for"),
)


Expand All @@ -24,7 +22,7 @@ class EditProfileForm(forms.Form):
__("Welcome message"),
validators=[
forms.validators.DataRequired(
_(u"Please write a message for the landing page")
_("Please write a message for the landing page")
)
],
description=__("This welcome message will be shown on the landing page."),
Expand All @@ -39,8 +37,8 @@ class EditProfileForm(forms.Form):
],
)
admin_team = QuerySelectField(
u"Admin Team",
validators=[forms.validators.DataRequired(_(u"Please select a team"))],
"Admin Team",
validators=[forms.validators.DataRequired(_("Please select a team"))],
get_label='title',
allow_blank=True,
blank_text=__("Choose a team..."),
Expand Down
45 changes: 22 additions & 23 deletions funnel/forms/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ class ProjectForm(forms.Form):
description=__("The timezone in which this event occurs"),
validators=[forms.validators.DataRequired()],
choices=sorted_timezones(),
default=u'UTC',
default='UTC',
)
bg_image = forms.URLField(
__("Banner image URL"),
description=u"Banner image for project cards on the homepage",
description="Banner image for project cards on the homepage",
validators=[
forms.validators.Optional(),
forms.validators.ValidUrl(),
Expand All @@ -99,12 +99,12 @@ class ProjectForm(forms.Form):
"RGB color for the project. Enter without the '#'. E.g. CCCCCC."
),
validators=[forms.validators.Optional(), forms.validators.Length(max=6)],
default=u"CCCCCC",
default="CCCCCC",
)
explore_url = forms.URLField(
__("Explore tab URL"),
description=__(
u"Page containing the explore tab’s contents, for the mobile app"
"Page containing the explore tab’s contents, for the mobile app"
),
validators=[
forms.validators.Optional(),
Expand All @@ -113,39 +113,36 @@ class ProjectForm(forms.Form):
],
)
parent_project = QuerySelectField(
__(u"Parent project"),
get_label='title',
allow_blank=True,
blank_text=__(u"None"),
__("Parent project"), get_label='title', allow_blank=True, blank_text=__("None")
)

admin_team = QuerySelectField(
u"Admin team",
validators=[forms.validators.DataRequired(__(u"Please select a team"))],
"Admin team",
validators=[forms.validators.DataRequired(__("Please select a team"))],
get_label='title',
allow_blank=False,
description=__(u"The administrators of this project"),
description=__("The administrators of this project"),
)
review_team = QuerySelectField(
u"Review team",
validators=[forms.validators.DataRequired(__(u"Please select a team"))],
"Review team",
validators=[forms.validators.DataRequired(__("Please select a team"))],
get_label='title',
allow_blank=False,
description=__(
u"Reviewers can see contact details of proposers, but can’t change settings"
"Reviewers can see contact details of proposers, but can’t change settings"
),
)
checkin_team = QuerySelectField(
u"Checkin team",
validators=[forms.validators.DataRequired(__(u"Please select a team"))],
"Checkin team",
validators=[forms.validators.DataRequired(__("Please select a team"))],
get_label='title',
allow_blank=False,
description=__(u"Team members can check in users at an event"),
description=__("Team members can check in users at an event"),
)
allow_rsvp = forms.BooleanField(__("Allow site visitors to RSVP (login required)"))
buy_tickets_url = forms.URLField(
__("URL to buy tickets"),
description=__(u"Eg: Explara, Instamojo"),
description=__("Eg: Explara, Instamojo"),
validators=[
forms.validators.Optional(),
forms.validators.URL(),
Expand Down Expand Up @@ -177,7 +174,7 @@ class CfpForm(forms.Form):
instructions = forms.MarkdownField(
__("Call for proposals"),
validators=[forms.validators.DataRequired()],
default=u'',
default='',
)
cfp_start_at = forms.DateTimeField(
__("Submissions open at"), validators=[forms.validators.Optional()], naive=False
Expand Down Expand Up @@ -205,7 +202,7 @@ class ProjectTransitionForm(forms.Form):
)

def set_queries(self):
self.transition.choices = self.edit_obj.state.transitions().items()
self.transition.choices = list(self.edit_obj.state.transitions().items())


class ProjectScheduleTransitionForm(forms.Form):
Expand All @@ -214,7 +211,7 @@ class ProjectScheduleTransitionForm(forms.Form):
)

def set_queries(self):
self.schedule_transition.choices = (
self.schedule_transition.choices = list(
self.edit_obj.schedule_state.transitions().items()
)

Expand All @@ -225,7 +222,9 @@ class ProjectCfpTransitionForm(forms.Form):
)

def set_queries(self):
self.cfp_transition.choices = self.edit_obj.cfp_state.transitions().items()
self.cfp_transition.choices = list(
self.edit_obj.cfp_state.transitions().items()
)


class SavedProjectForm(forms.Form):
Expand Down Expand Up @@ -260,7 +259,7 @@ class EventForm(forms.Form):
)
badge_template = forms.URLField(
__("Badge template URL"),
description=u"URL of background image for the badge",
description="URL of background image for the badge",
validators=[forms.validators.Optional(), forms.validators.ValidUrl()],
)

Expand Down
6 changes: 3 additions & 3 deletions funnel/forms/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class ProposalForm(forms.Form):
__("Are you speaking?"),
coerce=int,
choices=[
(1, __(u"I will be speaking")),
(0, __(u"I’m proposing a topic for someone to speak on")),
(1, __("I will be speaking")),
(0, __("I’m proposing a topic for someone to speak on")),
],
)
title = forms.StringField(
Expand Down Expand Up @@ -231,7 +231,7 @@ def set_queries(self):
label: transition object itself
We need the whole object to get the additional metadata in templates
"""
self.transition.choices = self.edit_obj.state.transitions().items()
self.transition.choices = list(self.edit_obj.state.transitions().items())


class ProposalMoveForm(forms.Form):
Expand Down
2 changes: 1 addition & 1 deletion funnel/forms/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SessionForm(forms.Form):
)
banner_image_url = forms.URLField(
__("Banner image URL"),
description=u"Banner image for session card",
description="Banner image for session card",
validators=[
forms.validators.Optional(),
forms.validators.ValidUrl(),
Expand Down
2 changes: 1 addition & 1 deletion funnel/forms/venue.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class VenueRoomForm(forms.Form):
__("Event Color"),
validators=[forms.validators.DataRequired(), forms.validators.Length(max=6)],
description=__("RGB Color for the event. Enter without the '#'. E.g. CCCCCC."),
default=u"CCCCCC",
default="CCCCCC",
)

def validate_bgcolor(self, field):
Expand Down
6 changes: 3 additions & 3 deletions funnel/jobs/jobs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from collections import defaultdict
from urlparse import urljoin
from urllib.parse import urljoin

import requests

Expand All @@ -16,12 +16,12 @@ def import_tickets(ticket_client_id):
with funnelapp.app_context():
ticket_client = TicketClient.query.get(ticket_client_id)
if ticket_client:
if ticket_client.name.lower() == u'explara':
if ticket_client.name.lower() == 'explara':
ticket_list = ExplaraAPI(
access_token=ticket_client.client_access_token
).get_tickets(ticket_client.client_eventid)
ticket_client.import_from_list(ticket_list)
elif ticket_client.name.lower() == u'boxoffice':
elif ticket_client.name.lower() == 'boxoffice':
ticket_list = Boxoffice(
access_token=ticket_client.client_access_token
).get_tickets(ticket_client.client_eventid)
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/contact_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ContactExchange(TimestampMixin, RoleMixin, db.Model):
db.TIMESTAMP(timezone=True), nullable=False, default=db.func.utcnow()
)
#: Note recorded by the user (plain text)
description = db.Column(db.UnicodeText, nullable=False, default=u'')
description = db.Column(db.UnicodeText, nullable=False, default='')
#: Archived flag
archived = db.Column(db.Boolean, nullable=False, default=False)

Expand Down
6 changes: 3 additions & 3 deletions funnel/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def make_key():
return unicode(base64.urlsafe_b64encode(os.urandom(128)))
return base64.urlsafe_b64encode(os.urandom(128)).decode('utf-8')


def make_public_key():
Expand Down Expand Up @@ -317,13 +317,13 @@ def import_from_list(self, ticket_list):
)
if ticket and (
ticket.participant is not participant
or ticket_dict.get('status') == u'cancelled'
or ticket_dict.get('status') == 'cancelled'
):
# Ensure that the participant of a transferred or cancelled ticket does not have access to
# this ticket's events
ticket.participant.remove_events(ticket_type.events)

if ticket_dict.get('status') == u'confirmed':
if ticket_dict.get('status') == 'confirmed':
ticket = SyncTicket.upsert(
self,
ticket_dict.get('order_no'),
Expand Down
1 change: 0 additions & 1 deletion funnel/models/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from textwrap import dedent

Expand Down
4 changes: 2 additions & 2 deletions funnel/models/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Label(BaseScopedNameMixin, db.Model):
seq = db.Column(db.Integer, nullable=False)

# A single-line description of this label, shown when picking labels (optional)
description = db.Column(db.UnicodeText, nullable=False, default=u"")
description = db.Column(db.UnicodeText, nullable=False, default="")

#: Icon for displaying in space-constrained UI. Contains one emoji symbol.
#: Since emoji can be composed from multiple symbols, there is no length
Expand Down Expand Up @@ -128,7 +128,7 @@ class Label(BaseScopedNameMixin, db.Model):
@property
def title_for_name(self):
if self.main_label:
return u"%s/%s" % (self.main_label.title, self.title)
return "%s/%s" % (self.main_label.title, self.title)
else:
return self.title

Expand Down
2 changes: 1 addition & 1 deletion funnel/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Profile(UseridMixin, UuidMixin, ProfileBase, db.Model):
)
admin_team = db.relationship(Team)

description = MarkdownColumn('description', default=u'', nullable=False)
description = MarkdownColumn('description', default='', nullable=False)
logo_url = db.Column(UrlType, nullable=True)
#: Legacy profiles are available via funnelapp, non-legacy in the main app
legacy = db.Column(db.Boolean, default=False, nullable=False)
Expand Down
Loading