Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitoliv committed Jun 20, 2021
2 parents 26e1fd4 + 4b6a8c6 commit 63bb63a
Show file tree
Hide file tree
Showing 55 changed files with 3,554 additions and 2,620 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 3.0.0 (2021-06-20)
--------------------------
* [FEAT]: Update the TMVDB Logo (#116)
* [FEAT]: TV show ranking feature (#121)
* [FIX]: Fix CKEditor display on the Mark movie page (#122)
* [FIX]: Code cleaning and refactoring (#124)

Version 2.3.0 (2021-03-22)
--------------------------
* [FEAT]: Migrate to python 3 / Upgrade dependencies (#114)
Expand Down
60 changes: 47 additions & 13 deletions cineapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging, sys, os
from logging.handlers import RotatingFileHandler
from flask_socketio import SocketIO
from flask_migrate import Migrate
from flask_msearch import Search

app = Flask(__name__)
Expand All @@ -21,19 +22,19 @@
app.wsgi_app = ProxyFix(app.wsgi_app)

# Global Variables
app.config['VERSION'] = "2.3.0"
app.config['VERSION'] = "3.0.0"
app.config['GRAVATAR_URL'] = "https://www.gravatar.com/avatar/"
app.config['GRAPH_LIST'] = [
{ "graph_endpoint": "graph_by_mark", "graph_label": u"Répartition par note" },
{ "graph_endpoint": "graph_by_mark_percent", "graph_label": u"Répartition par note (en %)" },
{ "graph_endpoint": "graph_by_mark_interval", "graph_label": u"Répartition par intervalle" },
{ "graph_endpoint": "graph_by_type", "graph_label": u"Répartition par type" },
{ "graph_endpoint": "graph_by_origin", "graph_label": u"Répartition par origine" },
{ "graph_endpoint": "average_by_type", "graph_label": u"Moyenne par type" },
{ "graph_endpoint": "average_by_origin", "graph_label": u"Moyenne par origine" },
{ "graph_endpoint": "graph_by_year", "graph_label": u"Répartition par année" },
{ "graph_endpoint": "graph_by_year_theater", "graph_label": u"Films vus au ciné" },
{ "graph_endpoint": "average_by_year", "graph_label": u"Moyenne par année" }
{ "graph_endpoint": "graphs.graph_by_mark", "graph_label": u"Répartition par note", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.graph_by_mark_percent", "graph_label": u"Répartition par note (en %)", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.graph_by_mark_interval", "graph_label": u"Répartition par intervalle", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.graph_by_type", "graph_label": u"Répartition par type", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.graph_by_origin", "graph_label": u"Répartition par origine", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.average_by_type", "graph_label": u"Moyenne par type", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.average_by_origin", "graph_label": u"Moyenne par origine", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.graph_by_year", "graph_label": u"Répartition par année", "movie": True, "tvshow": True },
{ "graph_endpoint": "graphs.graph_by_year_theater", "graph_label": u"Films vus au ciné", "movie": True, "tvshow": False },
{ "graph_endpoint": "graphs.average_by_year", "graph_label": u"Moyenne par année", "movie": True, "tvshow": True }
]

# Upload image control
Expand All @@ -48,14 +49,36 @@
app.config['POSTERS_URL'] = "/static/posters/"

# TMVDB parameters
app.config['TMVDB_BASE_URL'] = "https://themoviedb.org/movie"
app.config['TMVDB_BASE_URL'] = "https://themoviedb.org/"

# Configuration file reading
if os.environ.get('TEST') == "yes":
app.config.from_pyfile('../configs/settings_test.cfg')
else:
app.config.from_pyfile(os.path.join(app.root_path,'../configs/settings.cfg'))

# Intialize Slack configuration
if "SLACK_NOTIFICATION_ENABLE" in app.config:
if app.config['SLACK_NOTIFICATION_ENABLE'] == True:

# We want to use Slack notifications ==> Let's define channels
app.config['SLACK_NOTIFICATION_CHANNEL']={}

# For movies
if "SLACK_NOTIFICATION_CHANNEL_MOVIES" in app.config and app.config['SLACK_NOTIFICATION_CHANNEL_MOVIES'] != None:
app.config['SLACK_NOTIFICATION_CHANNEL']['movie']=app.config['SLACK_NOTIFICATION_CHANNEL_MOVIES']
else:
app.config['SLACK_NOTIFICATION_CHANNEL']['movie']=None

# For tvshows
if "SLACK_NOTIFICATION_CHANNEL_TVSHOWS" in app.config and app.config['SLACK_NOTIFICATION_CHANNEL_TVSHOWS'] != None:
app.config['SLACK_NOTIFICATION_CHANNEL']['tvshow']=app.config['SLACK_NOTIFICATION_CHANNEL_TVSHOWS']
else:
app.config['SLACK_NOTIFICATION_CHANNEL']['tvshow']=None
else:
print("SLACK_NOTIFICATION_ENABLE not defined in configuration file")
sys.exit(2)

# Check if API_KEY is defined
for cur_item in [ "API_KEY", "SLACK_TOKEN" ]:
if cur_item not in app.config:
Expand All @@ -65,6 +88,7 @@

# Database Initialization
db = SQLAlchemy(app)
migrate = Migrate(app,db)

# Login manager init
lm = LoginManager()
Expand Down Expand Up @@ -116,4 +140,14 @@
app.logger.addHandler(file_handler)
app.logger.info('Cineapp startup')

from cineapp import views, models, jinja_filters, chat, comments, favorites
# Blueprint Registration
from cineapp.shows import show_bp
from cineapp.homeworks import homework_bp
from cineapp.profile import profile_bp
from cineapp.graphs import graph_bp
app.register_blueprint(show_bp)
app.register_blueprint(homework_bp)
app.register_blueprint(profile_bp)
app.register_blueprint(graph_bp)

from cineapp import views, models, jinja_filters, chat, comments, favorites, jinja_testers
16 changes: 8 additions & 8 deletions cineapp/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from functools import wraps
from flask_login import current_user
from flask import flash, redirect, url_for
from flask import flash, redirect, url_for, g

def guest_control(func):
@wraps(func)
def decorated_view(*args, **kwargs):
if current_user.is_guest == True:
flash("Accès interdit pour les invités","danger")
return redirect(url_for('list_movies'))
return func(*args, **kwargs)
return decorated_view
@wraps(func)
def decorated_view(*args, **kwargs):
if current_user.is_guest == True:
flash("Accès interdit pour les invités","danger")
return redirect(url_for('show.list_shows',show_type=g.show_type))
return func(*args, **kwargs)
return decorated_view
8 changes: 4 additions & 4 deletions cineapp/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def add_mark_comment():
# Fetch the important informations we need to fill the chat message object
comment = request.form["comment"]
dest_user = request.form["dest_user"]
movie_id = request.form["movie_id"]
show_id = request.form["show_id"]

# Create the chat_message object
mark_comment=MarkComment()
mark_comment.user_id = g.user.id
mark_comment.mark_user_id = dest_user
mark_comment.mark_movie_id = movie_id
mark_comment.mark_show_id = show_id
mark_comment.posted_when = datetime.now()
mark_comment.message = comment

Expand All @@ -44,7 +44,7 @@ def add_mark_comment():
mark_comment_notification(mark_comment,"add_mark_comment")

# Build the dict we're going to send to the frontend
data_dict = { "user": g.user.serialize(), "mark_comment": mark_comment.serialize(), "mark_comment_number": MarkComment.query.filter(MarkComment.mark_user_id==dest_user,MarkComment.mark_movie_id==movie_id,MarkComment.deleted_when==None).count()}
data_dict = { "user": g.user.serialize(), "mark_comment": mark_comment.serialize(), "mark_comment_number": MarkComment.query.filter(MarkComment.mark_user_id==dest_user,MarkComment.mark_show_id==show_id,MarkComment.deleted_when==None).count()}

# Format the date for correct JS display
data_dict["mark_comment"]["posted_when"] = data_dict["mark_comment"]["posted_when"].strftime("%d/%m/%Y - %H:%M:%S");
Expand Down Expand Up @@ -99,4 +99,4 @@ def update_mark_comment():
return jsonify( { "error":u"Commentaire inexistant ou déjà supprimé", "markcomment_id": comment_id } )

# Let's send the MarkComment as a JSON object to the frontend
return jsonify( { "operation": request.endpoint , "mark_comment": mark_comment.serialize(), "mark_comment_number": MarkComment.query.filter(MarkComment.mark_user_id==mark_comment.mark_user_id,MarkComment.mark_movie_id==mark_comment.mark_movie_id,MarkComment.deleted_when==None).count() })
return jsonify( { "operation": request.endpoint , "mark_comment": mark_comment.serialize(), "mark_comment_number": MarkComment.query.filter(MarkComment.mark_user_id==mark_comment.mark_user_id,MarkComment.mark_show_id==mark_comment.mark_show_id,MarkComment.deleted_when==None).count() })
Loading

0 comments on commit 63bb63a

Please sign in to comment.