Skip to content

Commit

Permalink
Merge branch 'develop' into unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
U8NWXD committed Jan 18, 2019
2 parents 79ff251 + 0dd6f64 commit 2c404f7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
14 changes: 9 additions & 5 deletions culturemesh/blueprints/events/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from culturemesh.utils import get_network_title
from culturemesh.utils import get_event_location
from culturemesh.utils import safe_get_query_arg
from culturemesh.utils import is_logged_in

from culturemesh.blueprints.events.forms.event_forms import *
from culturemesh.blueprints.networks.utils import gather_network_info
Expand All @@ -24,7 +25,6 @@ def ping():
return c.ping_event()

@events.route("/")
#@login_required
def render_event():
current_event_id = request.args.get('id')
c = Client(mock=False)
Expand All @@ -40,28 +40,32 @@ def render_event():

role = None

if not current_user.is_anonymous:
if event['id_host'] == current_user.id:
if is_logged_in(current_user):
user_id = current_user.id
if event['id_host'] == user_id:

# The current user is hosting this event.
role = 'hosting'
host['username'] = 'you'

elif user_is_attending_event(c, current_user.id, event):
elif user_is_attending_event(c, user_id, event):

# The current user is already signed up for this event.
role = 'attending'
else:

# The current user is not signed up for this event.
pass
else:
user_id = None


return render_template(
'event.html',
event=event,
host=host,
role=role,
curr_user_id=current_user.id,
curr_user_id=user_id,
join_form=EventJoinForm(),
leave_form=EventLeaveForm(),
cancel_form=EventCancelForm()
Expand Down
14 changes: 5 additions & 9 deletions culturemesh/blueprints/networks/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from culturemesh.utils import get_network_title
from culturemesh.utils import get_upcoming_events_by_network
from culturemesh.utils import get_time_ago
from culturemesh.utils import is_logged_in
from utils import parse_date

from culturemesh.blueprints.networks.forms.network_forms import NetworkJoinForm
Expand All @@ -18,9 +19,6 @@

from culturemesh.blueprints.networks.utils import gather_network_info


#just adding this comment to test git

networks = Blueprint('networks', __name__, template_folder='templates')
utc=pytz.UTC

Expand Down Expand Up @@ -94,11 +92,10 @@ def network_events() :
utils.enhance_event_date_info(event)
event['num_registered'] = c.get_event_reg_count(event['id'])['reg_count']

id_user = current_user.get_id()
user_is_member = False

if not id_user == None:
user_networks = c.get_user_networks(id_user, count=100)
if is_logged_in(current_user):
user_networks = c.get_user_networks(current_user.get_id(), count=100)
for network_ in user_networks:
if int(id_network) == int(network_['id']):
user_is_member = True
Expand Down Expand Up @@ -167,10 +164,9 @@ def network_posts() :
else :
post_index = posts[-1]['id']

id_user = current_user.get_id()
user_is_member = False
if id_user is not None:
user_networks = c.get_user_networks(id_user, count=100)
if is_logged_in(current_user):
user_networks = c.get_user_networks(current_user.get_id(), count=100)
for network_ in user_networks:
if int(id_network) == int(network_['id']):
user_is_member = True
Expand Down
2 changes: 1 addition & 1 deletion culturemesh/blueprints/networks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def gather_network_info(id_network, id_user, client, scenario="normal"):
post['time_ago'] = get_time_ago(post['post_date'])

user_is_member = False
if id_user is not None:
if not id_user == None:
user_networks = client.get_user_networks(id_user, count=100)
for network_ in user_networks:
if int(id_network) == int(network_['id']):
Expand Down
4 changes: 2 additions & 2 deletions culturemesh/blueprints/posts/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from culturemesh.utils import get_time_ago
from culturemesh.utils import get_network_title
from culturemesh.utils import safe_get_query_arg
from culturemesh.utils import is_logged_in

from culturemesh.blueprints.posts.forms.post_forms import *

Expand All @@ -16,7 +17,6 @@
posts = Blueprint('posts', __name__, template_folder='templates')

@posts.route("/", methods=['GET', 'POST'])
#@flask_login.login_required
def render_post():

current_post_id = safe_get_query_arg(request, 'id')
Expand All @@ -41,7 +41,7 @@ def render_post():

if request.method == 'GET':
pass
elif user_id == None:
elif not is_logged_in(current_user):
return redirect(
url_for('render_login_page')
)
Expand Down
4 changes: 2 additions & 2 deletions culturemesh/blueprints/search/forms/search_forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, RadioField
from wtforms import StringField, SubmitField, SelectField
from wtforms.validators import DataRequired

class SearchForm(FlaskForm):
search_type = RadioField(
search_type = SelectField(
'Search Type',
choices=[('language', 'speak'), ('location', 'are from')]
)
Expand Down
2 changes: 1 addition & 1 deletion culturemesh/blueprints/user_home/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def update_profile_and_render_home():
'id': user_id, 'first_name': first_name,
'last_name': last_name, 'about_me': about_me
}

if form.validate():
c.update_user(current_user, user)

Expand Down
1 change: 0 additions & 1 deletion culturemesh/blueprints/users/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
users = Blueprint('users', __name__, template_folder='templates')

@users.route('/<int:user_id>/', methods=['GET'])
@flask_login.login_required
def user_profile(user_id):

c = Client(mock=False)
Expand Down
3 changes: 3 additions & 0 deletions culturemesh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,6 @@ def user_is_attending_event(client, user_id, event):
if user_id == reg['id_guest']:
return True
return False

def is_logged_in(current_user):
return current_user.get_id() != None

0 comments on commit 2c404f7

Please sign in to comment.