-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed renaming entities led to no images bug
- Loading branch information
jose.correia
committed
Oct 6, 2019
1 parent
b53160a
commit 4ee97a8
Showing
23 changed files
with
148 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
from .. import bp | ||
from flask import render_template, current_app, request, redirect, url_for | ||
from jeec_brain.handlers.event_handler import EventHandler | ||
from jeec_brain.services.users.get_roles_service import GetRolesService | ||
from jeec_brain.apps.auth.wrappers import allowed_roles | ||
from jeec_brain.models.enums.roles_enum import RolesEnum | ||
from flask_login import current_user | ||
|
||
|
||
@bp.route('/new-event', methods=['GET']) | ||
@allowed_roles(['admin') | ||
def add_event_dashboard(): | ||
return render_template('admin/event/add_event.html', \ | ||
error=None) | ||
|
||
|
||
@bp.route('/new-event', methods=['POST']) | ||
@allowed_roles(['admin']) | ||
def create_event(): | ||
# extract form parameters | ||
name = request.form.get('name') | ||
date = request.form.get('date') | ||
email = request.form.get('email') | ||
address = request.form.get('address') | ||
facebook_link = request.form.get('facebook_link') | ||
youtube_link = request.form.get('youtube_link') | ||
instagram_link = request.form.get('instagram_link') | ||
|
||
# create new user | ||
event = EventHandler.create_event( | ||
name=name, | ||
date=date, | ||
email=email, | ||
address=address, | ||
facebook_link=facebook_link, | ||
youtube_link=youtube_link, | ||
instagram_link=instagram_link | ||
) | ||
|
||
if user is None: | ||
return render_template('admin/event/add_event.html', \ | ||
error="Failed to create event!") | ||
|
||
return redirect(url_for('admin_api.get_event')) | ||
|
||
|
||
@bp.route('/event', methods=['GET']) | ||
@allowed_roles(['admin') | ||
def get_event(): | ||
event = EventsFinder.get_event() | ||
|
||
if event is None: | ||
return render_template(url_for('admin_api.add_event_dashboard')) | ||
|
||
logo = EventHandler.find_logo() | ||
logo_mobile = EventHandler.find_logo_mobile() | ||
return render_template('admin/event/update_event.html', company=company, image=image_path, error=None) | ||
|
||
|
||
@bp.route('/company/<string:company_external_id>', methods=['POST']) | ||
@allowed_roles(['admin', 'companies_admin']) | ||
def update_company(company_external_id): | ||
|
||
company = CompaniesFinder.get_from_external_id(company_external_id) | ||
|
||
if company is None: | ||
return APIErrorValue('Couldnt find company').json(500) | ||
|
||
name = request.form.get('name') | ||
date = request.form.get('date') | ||
email = request.form.get('email') | ||
address = request.form.get('address') | ||
facebook_link = request.form.get('facebook_link') | ||
youtube_link = request.form.get('youtube_link') | ||
instagram_link = request.form.get('instagram_link') | ||
|
||
image_path = CompaniesHandler.find_image(name) | ||
|
||
updated_event = EventHandler.update_event( | ||
name=name, | ||
date=date, | ||
email=email, | ||
address=address, | ||
facebook_link=facebook_link, | ||
youtube_link=youtube_link, | ||
instagram_link=instagram_link | ||
) | ||
|
||
if updated_event is None: | ||
return render_template('admin/event/update_event.html', event=event, image=image_path, error="Failed to update company!") | ||
|
||
if 'file' in request.files: | ||
file = request.files['file'] | ||
|
||
result, msg = CompaniesHandler.upload_image(file, name) | ||
|
||
if result == False: | ||
return render_template('admin/companies/update_company.html', company=updated_company, image=image_path, error=msg) | ||
|
||
return redirect(url_for('admin_api.companies_dashboard')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
jeec_brain/templates/admin/activities/activities_dashboard.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters