diff --git a/.env.sample b/.env.sample deleted file mode 100644 index 3bf87d7..0000000 --- a/.env.sample +++ /dev/null @@ -1 +0,0 @@ -THEATERS=[{"id":"C0071","name":"Écoles Cinéma Club","latitude":48.848363,"longitude":2.348973},{"id":"C2954","name":"MK2 Bibliothèque","latitude":48.832448,"longitude":2.375488},{"id":"C0050","name":"MK2 Beaubourg","latitude":48.861584,"longitude":2.352312},{"id":"W7504","name":"Épée de bois","latitude":48.8413,"longitude":2.349555},{"id":"C0076","name":"Cinéma du Panthéon","latitude":48.847488,"longitude":2.342385},{"id":"C0089","name":"Max Linder Panorama","latitude":48.87137,"longitude":2.344856},{"id":"C0013","name":"Luminor Hotel de Ville","latitude":48.858676,"longitude":2.353602},{"id":"C0072","name":"Le Grand Action","latitude":48.84753,"longitude":2.352129},{"id":"C0099","name":"MK2 Parnasse","latitude":48.842813,"longitude":2.330526},{"id":"C0073","name":"Le Champo","latitude":48.84998,"longitude":2.343223},{"id":"C0020","name":"Filmothèque du Quartier Latin","latitude":48.84951,"longitude":2.34279},{"id":"C0074","name":"Reflet Medicis","latitude":48.84951,"longitude":2.34279},{"id":"C0159","name":"UGC Ciné Cité Les Halles","latitude":48.849777,"longitude":2.343014},{"id":"C0026","name":"UGC Ciné Cité Bercy","latitude":48.832182,"longitude":2.385291}] diff --git a/.gitignore b/.gitignore index 6d95311..a589ee0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ __pycache__/ .vscode/ .venv -.DS_Store -.env +.DS_Store \ No newline at end of file diff --git a/app.py b/app.py index 34a388e..da2f49c 100644 --- a/app.py +++ b/app.py @@ -1,39 +1,34 @@ -import dotenv -import json -import os from flask import Flask, render_template, request from datetime import datetime, timedelta -# IMPORT DES MODULES +# IMPORT DES MODULES from modules.Classes import * -# On charge les variables d'environnement... -dotenv.load_dotenv(".env") -# et celles par défaut pour avoir la liste des cinémas -dotenv.load_dotenv(".env.sample") - -WEBSITE_TITLE = os.environ.get("WEBSITE_TITLE", "GrainParisArt") -MAPBOX_TOKEN = os.environ.get("MAPBOX_TOKEN", "") - -theaters_json = json.loads(os.environ.get("THEATERS", "[]")) +cinemas = { + "C0071": "Écoles Cinéma Club", + "C2954": "MK2 Bibliothèque", + "C0050": "MK2 Beaubourg", + "W7504": "Épée de bois", + "C0076": "Cinéma du Panthéon", + "C0089": "Max Linder Panorama", + "C0013": "Luminor Hotel de Ville", + "C0072": "Le Grand Action", + "C0099": "MK2 Parnasse", + "C0073": "Le Champo", + "C0020": "Filmothèque du Quartier Latin", + "C0074": "Reflet Medicis", + "C0159": "UGC Ciné Cité Les Halles", + "C0026": "UGC Ciné Cité Bercy" +} theaters: list[Theater] = [] -for theater in theaters_json: +for id, name in cinemas.items(): theaters.append(Theater({ - "name": theater["name"], - "internalId": theater["id"], - "latitude": theater["latitude"], - "longitude": theater["longitude"], + "name": name, + "internalId": id, "location": None })) -theater_locations = [] -for theater in theaters: - theater_locations.append({ - "coordinates": [theater.longitude, theater.latitude], - "description": theater.name, - }) - def getShowtimes(date): showtimes:list[Showtime] = [] @@ -61,7 +56,7 @@ def getShowtimes(date): "seances": {} } - + if theater.name not in data[movie.title]["seances"].keys(): data[movie.title]["seances"][theater.name] = [] @@ -131,15 +126,7 @@ def home(): "index": i }) - return render_template( - 'index.html', - page_actuelle='home', - films=showtimes[delta], - dates=dates, - theater_locations=theater_locations, - website_title=WEBSITE_TITLE, - mapbox_token=MAPBOX_TOKEN, - ) + return render_template('index.html', page_actuelle='home', films=showtimes[delta], dates=dates) if __name__ == '__main__': - app.run() \ No newline at end of file + app.run() \ No newline at end of file diff --git a/modules/Classes.py b/modules/Classes.py index 2dd47d5..b85889d 100644 --- a/modules/Classes.py +++ b/modules/Classes.py @@ -1,14 +1,6 @@ -from dataclasses import dataclass from datetime import datetime import requests -@dataclass -class Cinema: - id: str - name: str - latitude: float - longitude: float - class Movie: def __init__(self, data) -> None: self.data = data @@ -71,8 +63,6 @@ class Theater: self.name = data['name'] self.id = data['internalId'] self.location = data['location'] - self.latitude = data['latitude'] - self.longitude = data['longitude'] def __repr__(self) -> str: return f"<{self.__class__.__name__} name={self.name}>" diff --git a/requirements.txt b/requirements.txt index 9a1e985..0eb56cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ Flask -python-dotenv requests \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 4cd00f0..72ea9bd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,13 +7,13 @@ -
Quand ça va pas, y aura toujours le cinéma