diff --git a/README.md b/README.md index 3bc99f88a..00956ebc9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ -Fyyur +## Fyyur Project Details + ----- -## Introduction +### Introduction Fyyur is a musical venue and artist booking site that facilitates the discovery and bookings of shows between local performing artists and venues. This site lets you list new artists and venues, discover them, and list shows with artists as a venue owner. Your job is to build out the data models to power the API endpoints for the Fyyur site by connecting to a PostgreSQL database for storing, querying, and creating information about artists and venues on Fyyur. -## Overview +### Overview This app is nearly complete. It is only missing one thing… real data! While the views and controllers are defined in this application, it is missing models and model interactions to be able to store retrieve, and update data from a database. By the end of this project, you should have a fully functioning site that is at least capable of doing the following, if not more, using a PostgreSQL database: @@ -17,48 +18,32 @@ This app is nearly complete. It is only missing one thing… real data! While th We want Fyyur to be the next new platform that artists and musical venues can use to find each other, and discover new music shows. Let's make that happen! -## Tech Stack (Dependencies) - -### 1. Backend Dependencies -Our tech stack will include the following: - * **virtualenv** as a tool to create isolated Python environments - * **SQLAlchemy ORM** to be our ORM library of choice - * **PostgreSQL** as our database of choice - * **Python3** and **Flask** as our server language and server framework - * **Flask-Migrate** for creating and running schema migrations -You can download and install the dependencies mentioned above using `pip` as: -``` -pip install virtualenv -pip install SQLAlchemy -pip install postgres -pip install Flask -pip install Flask-Migrate -``` -> **Note** - If we do not mention the specific version of a package, then the default latest stable package will be installed. +### Prerequisites +- You must have the **HTML**, **CSS**, and **Javascript** with [Bootstrap 3](https://getbootstrap.com/docs/3.4/customize/) for our website's frontend. If you are working locally, further instructions are contained in the repo README file. -### 2. Frontend Dependencies -You must have the **HTML**, **CSS**, and **Javascript** with [Bootstrap 3](https://getbootstrap.com/docs/3.4/customize/) for our website's frontend. Bootstrap can only be installed by Node Package Manager (NPM). Therefore, if not already, download and install the [Node.js](https://nodejs.org/en/download/). Windows users must run the executable as an Administrator, and restart the computer after installation. After successfully installing the Node, verify the installation as shown below. -``` -node -v -npm -v -``` Install [Bootstrap 3](https://getbootstrap.com/docs/3.3/getting-started/) for the website's frontend: ``` npm init -y npm install bootstrap@3 ``` - +- Python 3.9 should be installed globally, preferably managed with [**pyenv**](https://github.com/pyenv/pyenv) +- Install [**postgresql**](https://www.postgresql.org/download/) +- Install [**poetry**](https://python-poetry.org/docs/) for virtual environment and dependencies management. ## Main Files: Project Structure ```sh ├── README.md - ├── app.py *** the main driver of the app. Includes your SQLAlchemy models. + ├── app.py *** the main driver of the app. "python app.py" to run after installing dependencies ├── config.py *** Database URLs, CSRF generation, etc ├── error.log ├── forms.py *** Your forms - ├── requirements.txt *** The dependencies we need to install with "pip3 install -r requirements.txt" + ├── model.py *** Your models + ├── poetry.lock *** Generated by poetry + ├── pyproject.toml *** The dependencies we need to install with "poetry install --no-root" + ├── util.py *** Helper functions + ├── validate.py *** Helper functions ├── static │   ├── css │   ├── font @@ -73,117 +58,33 @@ npm install bootstrap@3 ``` Overall: -* Models are located in the `MODELS` section of `app.py`. +* Models are located of `model.py`. * Controllers are also located in `app.py`. * The web frontend is located in `templates/`, which builds static assets deployed to the web server at `static/`. -* Web forms for creating data are located in `form.py` - - -Highlight folders: -* `templates/pages` -- (Already complete.) Defines the pages that are rendered to the site. These templates render views based on data passed into the template’s view, in the controllers defined in `app.py`. These pages successfully represent the data to the user, and are already defined for you. -* `templates/layouts` -- (Already complete.) Defines the layout that a page can be contained in to define footer and header code for a given page. -* `templates/forms` -- (Already complete.) Defines the forms used to create new artists, shows, and venues. -* `app.py` -- (Missing functionality.) Defines routes that match the user’s URL, and controllers which handle data and renders views to the user. This is the main file you will be working on to connect to and manipulate the database and render views with data to the user, based on the URL. -* Models in `app.py` -- (Missing functionality.) Defines the data models that set up the database tables. -* `config.py` -- (Missing functionality.) Stores configuration variables and instructions, separate from the main application code. This is where you will need to connect to the database. - - -Instructions ------ - -1. Understand the Project Structure (explained above) and where important files are located. -2. Build and run local development following the Development Setup steps below. -3. Fill in the missing functionality in this application: this application currently pulls in fake data, and needs to now connect to a real database and talk to a real backend. -4. Fill out every `TODO` section throughout the codebase. We suggest going in order of the following: - * Connect to a database in `config.py`. A project submission that uses a local database connection is fine. - * Using SQLAlchemy, set up normalized models for the objects we support in our web app in the Models section of `app.py`. Check out the sample pages provided at /artists/1, /venues/1, and /shows for examples of the data we want to model, using all of the learned best practices in database schema design. Implement missing model properties and relationships using database migrations via Flask-Migrate. - * Implement form submissions for creating new Venues, Artists, and Shows. There should be proper constraints, powering the `/create` endpoints that serve the create form templates, to avoid duplicate or nonsensical form submissions. Submitting a form should create proper new records in the database. - * Implement the controllers for listing venues, artists, and shows. Note the structure of the mock data used. We want to keep the structure of the mock data. - * Implement search, powering the `/search` endpoints that serve the application's search functionalities. - * Serve venue and artist detail pages, powering the `/` endpoints that power the detail pages. - -#### Data Handling with `Flask-WTF` Forms -The starter codes use an interactive form builder library called [Flask-WTF](https://flask-wtf.readthedocs.io/). This library provides useful functionality, such as form validation and error handling. You can peruse the Show, Venue, and Artist form builders in `forms.py` file. The WTForms are instantiated in the `app.py` file. For example, in the `create_shows()` function, the Show form is instantiated from the command: `form = ShowForm()`. To manage the request from Flask-WTF form, each field from the form has a `data` attribute containing the value from user input. For example, to handle the `venue_id` data from the Venue form, you can use: `show = Show(venue_id=form.venue_id.data)`, instead of using `request.form['venue_id']`. - -Acceptance Criteria ------ - -1. The web app should be successfully connected to a PostgreSQL database. A local connection to a database on your local computer is fine. -2. There should be no use of mock data throughout the app. The data structure of the mock data per controller should be kept unmodified when satisfied by real data. -3. The application should behave just as before with mock data, but now uses real data from a real backend server, with real search functionality. For example: - * when a user submits a new artist record, the user should be able to see it populate in /artists, as well as search for the artist by name and have the search return results. - * I should be able to go to the URL `/artist/` to visit a particular artist’s page using a unique ID per artist, and see real data about that particular artist. - * Venues should continue to be displayed in groups by city and state. - * Search should be allowed to be partial string matching and case-insensitive. - * Past shows versus Upcoming shows should be distinguished in Venue and Artist pages. - * A user should be able to click on the venue for an upcoming show in the Artist's page, and on that Venue's page, see the same show in the Venue Page's upcoming shows section. -4. As a fellow developer on this application, I should be able to run `flask db migrate`, and have my local database (once set up and created) be populated with the right tables to run this application and have it interact with my local postgres server, serving the application's needs completely with real data I can seed my local database with. - * The models should be completed (see TODOs in the `Models` section of `app.py`) and model the objects used throughout Fyyur. - * Define the models in a different file to follow [Separation of Concerns](https://en.wikipedia.org/wiki/Separation_of_concerns) design principles. You can refactor the models to a new file, such as `models.py`. - * The right _type_ of relationship and parent-child dynamics between models should be accurately identified and fit the needs of this particular application. - * The relationship between the models should be accurately configured, and referential integrity amongst the models should be preserved. - * `flask db migrate` should work, and populate my local postgres database with properly configured tables for this application's objects, including proper columns, column data types, constraints, defaults, and relationships that completely satisfy the needs of this application. The proper type of relationship between venues, artists, and shows should be configured. - -##### Stand Out - -Looking to go above and beyond? This is the right section for you! Here are some challenges to make your submission stand out: - -* Implement artist availability. An artist can list available times that they can be booked. Restrict venues from being able to create shows with artists during a show time that is outside of their availability. -* Show Recent Listed Artists and Recently Listed Venues on the homepage, returning results for Artists and Venues sorting by newly created. Limit to the 10 most recently listed items. -* Implement Search Artists by City and State, and Search Venues by City and State. Searching by "San Francisco, CA" should return all artists or venues in San Francisco, CA. - -Best of luck in your final project! Fyyur depends on you! - +* Web forms for creating data are located in `forms.py` ## Development Setup -1. **Download the project starter code locally** +1. **Setup virtual environment and install the dependencies:** ``` -git clone https://github.com/udacity/FSND.git -cd FSND/projects/01_fyyur/starter_code +poetry install --no-root ``` - -2. **Create an empty repository in your Github account online. To change the remote repository path in your local repository, use the commands below:** +2. **Create postgres DB 'fyyur'**: ``` -git remote -v -git remote remove origin -git remote add origin /.git> -git branch -M master +sudo -Hiu postgres createdb fyyur ``` -Once you have finished editing your code, you can push the local repository to your Github account using the following commands. +3. **Run flask-migrate to create the tables/relationships in the DB** ``` -git add . --all -git commit -m "your comment" -git push -u origin master +flask db init +flask db migrate -m 'Init migration' +flask db upgrade ``` -3. **Initialize and activate a virtualenv using:** -``` -python -m virtualenv env -source env/bin/activate -``` ->**Note** - In Windows, the `env` does not have a `bin` directory. Therefore, you'd use the analogous command shown below: +4. **Run the development server:** ``` -source env/Scripts/activate -``` - -4. **Install the dependencies:** -``` -pip install -r requirements.txt -``` - -5. **Run the development server:** -``` -export FLASK_APP=myapp +export FLASK_APP=app.py export FLASK_ENV=development # enables debug mode -python3 app.py +poetry run python app.py ``` -6. **Verify on the Browser**
-Navigate to project homepage [http://127.0.0.1:5000/](http://127.0.0.1:5000/) or [http://localhost:5000](http://localhost:5000) - -## Troubleshooting: -- If you encounter any dependency errors, please ensure that you are using Python 3.9 or lower. -- If you are still facing the dependency errors, follow the given commands: - - `using pip install --upgrade flask-moment` - - `Using pip install Werkzeug==2.0.0` - - `Using pip uninstall Flask and then pip install flask==2.0.3` +3. **Verify on the Browser**
+Navigate to project homepage in the virtual desktop (by clicking the DESKTOP button in the workspace) [http://127.0.0.1:5000/] (http://127.0.0.1:5000/) or [http://localhost:5000](http://localhost:5000) or in your local virtual environment. diff --git a/app.py b/app.py index ed56020d7..3566d6615 100644 --- a/app.py +++ b/app.py @@ -1,17 +1,24 @@ #----------------------------------------------------------------------------# # Imports #----------------------------------------------------------------------------# - -import json -import dateutil.parser -import babel -from flask import Flask, render_template, request, Response, flash, redirect, url_for -from flask_moment import Moment -from flask_sqlalchemy import SQLAlchemy +from datetime import datetime import logging from logging import Formatter, FileHandler -from flask_wtf import Form -from forms import * + +from flask import ( + abort, + Flask, render_template, + request, + flash, redirect, + url_for, +) +from flask_moment import Moment +from flask_migrate import Migrate + +from forms import ArtistForm, ShowForm, VenueForm +from model import Artist, db, Show, Venue +from util import format_datetime + #----------------------------------------------------------------------------# # App Config. #----------------------------------------------------------------------------# @@ -19,477 +26,517 @@ app = Flask(__name__) moment = Moment(app) app.config.from_object('config') -db = SQLAlchemy(app) - -# TODO: connect to a local postgresql database +db.init_app(app) +migrate = Migrate(app, db) #----------------------------------------------------------------------------# -# Models. +# Filters #----------------------------------------------------------------------------# -class Venue(db.Model): - __tablename__ = 'Venue' - - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String) - city = db.Column(db.String(120)) - state = db.Column(db.String(120)) - address = db.Column(db.String(120)) - phone = db.Column(db.String(120)) - image_link = db.Column(db.String(500)) - facebook_link = db.Column(db.String(120)) - - # TODO: implement any missing fields, as a database migration using Flask-Migrate - -class Artist(db.Model): - __tablename__ = 'Artist' - - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String) - city = db.Column(db.String(120)) - state = db.Column(db.String(120)) - phone = db.Column(db.String(120)) - genres = db.Column(db.String(120)) - image_link = db.Column(db.String(500)) - facebook_link = db.Column(db.String(120)) - - # TODO: implement any missing fields, as a database migration using Flask-Migrate - -# TODO Implement Show and Artist models, and complete all model relationships and properties, as a database migration. - -#----------------------------------------------------------------------------# -# Filters. -#----------------------------------------------------------------------------# - -def format_datetime(value, format='medium'): - date = dateutil.parser.parse(value) - if format == 'full': - format="EEEE MMMM, d, y 'at' h:mma" - elif format == 'medium': - format="EE MM, dd, y h:mma" - return babel.dates.format_datetime(date, format, locale='en') - app.jinja_env.filters['datetime'] = format_datetime #----------------------------------------------------------------------------# -# Controllers. +# Controllers #----------------------------------------------------------------------------# -@app.route('/') +@app.route('/', methods=['GET']) def index(): - return render_template('pages/home.html') + return render_template('pages/home.html') # Venues # ---------------------------------------------------------------- -@app.route('/venues') -def venues(): - # TODO: replace with real venues data. - # num_upcoming_shows should be aggregated based on number of upcoming shows per venue. - data=[{ - "city": "San Francisco", - "state": "CA", - "venues": [{ - "id": 1, - "name": "The Musical Hop", - "num_upcoming_shows": 0, - }, { - "id": 3, - "name": "Park Square Live Music & Coffee", - "num_upcoming_shows": 1, - }] - }, { - "city": "New York", - "state": "NY", - "venues": [{ - "id": 2, - "name": "The Dueling Pianos Bar", - "num_upcoming_shows": 0, - }] - }] - return render_template('pages/venues.html', areas=data); +@app.route('/venues', methods=['GET']) +def venues(): + try: + venue_groups = db.session.query(Venue.city, Venue.state)\ + .group_by(Venue.city, Venue.state)\ + .order_by(Venue.state).all() + resp = [] + for group in venue_groups: + venues_in_group = [] + + city = group[0] + state = group[1] + venues = db.session.query(Venue).filter(Venue.city == city, Venue.state == state).all() + + for venue in venues: + venues_in_group.append({ + 'id': venue.id, + 'name': venue.name, + 'num_upcoming_shows': len(db.session.query(Show) + .filter(Show.venue_id == venue.id) + .filter(Show.start_time > datetime.now()) + .all() + ) + }) + + sorted_num_shows_desc = sorted(venues_in_group, + key=lambda x: x['num_upcoming_shows'], + reverse=True) + resp.append({ + 'city': city, + 'state': state, + 'venues': sorted_num_shows_desc, + }) + app.logger.info('RESPONSE', resp) + return render_template('pages/venues.html', areas=resp) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() + @app.route('/venues/search', methods=['POST']) def search_venues(): - # TODO: implement search on artists with partial string search. Ensure it is case-insensitive. - # seach for Hop should return "The Musical Hop". - # search for "Music" should return "The Musical Hop" and "Park Square Live Music & Coffee" - response={ - "count": 1, - "data": [{ - "id": 2, - "name": "The Dueling Pianos Bar", - "num_upcoming_shows": 0, - }] - } - return render_template('pages/search_venues.html', results=response, search_term=request.form.get('search_term', '')) + search_term = request.form.get('search_term', '') + try: + results = db.session.query(Venue).filter(Venue.name.ilike(f'%{search_term}%')).all() + data = [] + for result in results: + data.append({ + 'id': result.id, + 'name': result.name, + 'num_upcoming_shows': len(db.session.query(Show) + .filter(Show.venue_id == result.id) + .filter(Show.start_time > datetime.now()) + .all()), + }) + return render_template( + 'pages/search_venues.html', + results={'count': len(results), 'data': data}, + search_term=search_term, + ) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() + @app.route('/venues/') def show_venue(venue_id): - # shows the venue page with the given venue_id - # TODO: replace with real venue data from the venues table, using venue_id - data1={ - "id": 1, - "name": "The Musical Hop", - "genres": ["Jazz", "Reggae", "Swing", "Classical", "Folk"], - "address": "1015 Folsom Street", - "city": "San Francisco", - "state": "CA", - "phone": "123-123-1234", - "website": "https://www.themusicalhop.com", - "facebook_link": "https://www.facebook.com/TheMusicalHop", - "seeking_talent": True, - "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", - "image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", - "past_shows": [{ - "artist_id": 4, - "artist_name": "Guns N Petals", - "artist_image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80", - "start_time": "2019-05-21T21:30:00.000Z" - }], - "upcoming_shows": [], - "past_shows_count": 1, - "upcoming_shows_count": 0, - } - data2={ - "id": 2, - "name": "The Dueling Pianos Bar", - "genres": ["Classical", "R&B", "Hip-Hop"], - "address": "335 Delancey Street", - "city": "New York", - "state": "NY", - "phone": "914-003-1132", - "website": "https://www.theduelingpianos.com", - "facebook_link": "https://www.facebook.com/theduelingpianos", - "seeking_talent": False, - "image_link": "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80", - "past_shows": [], - "upcoming_shows": [], - "past_shows_count": 0, - "upcoming_shows_count": 0, - } - data3={ - "id": 3, - "name": "Park Square Live Music & Coffee", - "genres": ["Rock n Roll", "Jazz", "Classical", "Folk"], - "address": "34 Whiskey Moore Ave", - "city": "San Francisco", - "state": "CA", - "phone": "415-000-1234", - "website": "https://www.parksquarelivemusicandcoffee.com", - "facebook_link": "https://www.facebook.com/ParkSquareLiveMusicAndCoffee", - "seeking_talent": False, - "image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", - "past_shows": [{ - "artist_id": 5, - "artist_name": "Matt Quevedo", - "artist_image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80", - "start_time": "2019-06-15T23:00:00.000Z" - }], - "upcoming_shows": [{ - "artist_id": 6, - "artist_name": "The Wild Sax Band", - "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", - "start_time": "2035-04-01T20:00:00.000Z" - }, { - "artist_id": 6, - "artist_name": "The Wild Sax Band", - "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", - "start_time": "2035-04-08T20:00:00.000Z" - }, { - "artist_id": 6, - "artist_name": "The Wild Sax Band", - "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", - "start_time": "2035-04-15T20:00:00.000Z" - }], - "past_shows_count": 1, - "upcoming_shows_count": 1, - } - data = list(filter(lambda d: d['id'] == venue_id, [data1, data2, data3]))[0] - return render_template('pages/show_venue.html', venue=data) - -# Create Venue -# ---------------------------------------------------------------- + try: + venue = db.session.query(Venue).filter(Venue.id == venue_id).one_or_none() + if not venue: + abort(404) + + return render_template('pages/show_venue.html', venue=venue.to_dict()) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() + @app.route('/venues/create', methods=['GET']) def create_venue_form(): - form = VenueForm() - return render_template('forms/new_venue.html', form=form) + form = VenueForm() + return render_template('forms/new_venue.html', form=form) + @app.route('/venues/create', methods=['POST']) def create_venue_submission(): - # TODO: insert form data as a new Venue record in the db, instead - # TODO: modify data to be the data object returned from db insertion + form = VenueForm(request.form, meta={'csrf': False}) + if form.validate(): + name = form.name.data + city = form.city.data + + try: + exists = db.session.query(Venue).filter(Venue.name == name, + Venue.city == city)\ + .one_or_none() + if exists: + flash(f'"{name}" already exists in {city}.') + return redirect(url_for('create_venue_form')) + + new_venue = Venue(name=name, city=city, state=form.state.data, address=form.address.data, + phone=form.phone.data, image_link=form.image_link.data, + facebook_link=form.facebook_link.data, website=form.website_link.data, + seeking_talent=form.seeking_talent.data, + seeking_description=form.seeking_description.data, + genres=form.genres.data) + db.session.add(new_venue) + db.session.commit() + flash(f'Venue "{name}" successfully listed!') + return render_template('pages/home.html') + + except Exception as e: + app.logger.error(e) + flash(f'An error occurred. Venue "{name}" could not be listed.') + db.session.rollback() + return redirect(url_for('create_venue_form')) + + finally: + db.session.close() + + else: + message = [] + for field, errors in form.errors.items(): + for err in errors: + message.append(f'{field}: {err}') + flash('Please fix the following errors: ' + ', '.join(message)) + return redirect(url_for('create_venue_form')) + + +@app.route('/venues//delete', methods=['POST']) +def delete_venue(venue_id): + try: + exists = db.session.query(Venue).filter(Venue.id == venue_id).one_or_none() + db.session.delete(exists) + db.session.commit() + flash(f'Venue "{exists.name}" has been successfully removed.') + return redirect(url_for('show_venue')) + + except Exception as e: + db.session.rollback() + app.logger.error(e) + flash('An error has occured.') + return redirect(url_for('show_venue')) + + finally: + db.session.close() + - # on successful db insert, flash success - flash('Venue ' + request.form['name'] + ' was successfully listed!') - # TODO: on unsuccessful db insert, flash an error instead. - # e.g., flash('An error occurred. Venue ' + data.name + ' could not be listed.') - # see: http://flask.pocoo.org/docs/1.0/patterns/flashing/ - return render_template('pages/home.html') +@app.route('/venues//edit', methods=['GET']) +def edit_venue(venue_id): + try: + venue = db.session.query(Venue).filter(Venue.id == venue_id).one_or_none() + if not venue: + abort(404) + + form = VenueForm(obj=venue) + return render_template('forms/edit_venue.html', form=form, venue=venue) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() -@app.route('/venues/', methods=['DELETE']) -def delete_venue(venue_id): - # TODO: Complete this endpoint for taking a venue_id, and using - # SQLAlchemy ORM to delete a record. Handle cases where the session commit could fail. - # BONUS CHALLENGE: Implement a button to delete a Venue on a Venue Page, have it so that - # clicking that button delete it from the db then redirect the user to the homepage - return None +@app.route('/venues//edit', methods=['POST']) +def edit_venue_submission(venue_id): + form = VenueForm(request.form, meta={'csrf': False}) + venue = db.session.query(Venue).filter(Venue.id == venue_id).one_or_none() + + if form.validate(): + try: + venue.name = form.name.data + venue.city = form.city.data + venue.state = form.state.data + venue.address = form.address.data + venue.phone = form.phone.data + venue.image_link = form.image_link.data + venue.facebook_link = form.facebook_link.data + venue.website = form.website_link.data + venue.seeking_talent = form.seeking_talent.data + venue.seeking_description = form.seeking_description.data + venue.genres = form.genres.data + + db.session.commit() + flash('Venue updated successfuly!') + return redirect(url_for('show_venue', venue_id=venue_id)) + + except Exception as e: + app.logger.error(e) + flash('Unsuccessful update.') + db.session.rollback() + return redirect(url_for('edit_venue', venue_id=venue_id)) + + finally: + db.session.close() + + else: + message = [] + for field, errors in form.errors.items(): + for err in errors: + message.append(f'{field}: {err}') + flash('Please fix the following errors: ' + ', '.join(message)) + return redirect(url_for('edit_venue', venue_id=venue_id)) + # Artists # ---------------------------------------------------------------- + @app.route('/artists') def artists(): - # TODO: replace with real data returned from querying the database - data=[{ - "id": 4, - "name": "Guns N Petals", - }, { - "id": 5, - "name": "Matt Quevedo", - }, { - "id": 6, - "name": "The Wild Sax Band", - }] - return render_template('pages/artists.html', artists=data) + try: + artists = db.session.query(Artist).all() + data = [] + for artist in artists: + data.append({ + 'id': artist.id, + 'name': artist.name, + }) + return render_template('pages/artists.html', artists=data) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() + @app.route('/artists/search', methods=['POST']) def search_artists(): - # TODO: implement search on artists with partial string search. Ensure it is case-insensitive. - # seach for "A" should return "Guns N Petals", "Matt Quevado", and "The Wild Sax Band". - # search for "band" should return "The Wild Sax Band". - response={ - "count": 1, - "data": [{ - "id": 4, - "name": "Guns N Petals", - "num_upcoming_shows": 0, - }] - } - return render_template('pages/search_artists.html', results=response, search_term=request.form.get('search_term', '')) + search_term = request.form.get('search_term', '') + try: + results = db.session.query(Artist).filter(Artist.name.ilike(f'%{search_term}%')).all() + data = [] + for result in results: + data.append({ + 'id': result.id, + 'name': result.name, + 'num_upcoming_shows': len(db.session.query(Show) + .filter(Show.artist_id == result.id) + .filter(Show.start_time > datetime.now()) + .all()), + }) + return render_template( + 'pages/search_artists.html', + results={'count': len(results), 'data': data}, + search_term=search_term, + ) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() + @app.route('/artists/') def show_artist(artist_id): - # shows the artist page with the given artist_id - # TODO: replace with real artist data from the artist table, using artist_id - data1={ - "id": 4, - "name": "Guns N Petals", - "genres": ["Rock n Roll"], - "city": "San Francisco", - "state": "CA", - "phone": "326-123-5000", - "website": "https://www.gunsnpetalsband.com", - "facebook_link": "https://www.facebook.com/GunsNPetals", - "seeking_venue": True, - "seeking_description": "Looking for shows to perform at in the San Francisco Bay Area!", - "image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80", - "past_shows": [{ - "venue_id": 1, - "venue_name": "The Musical Hop", - "venue_image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", - "start_time": "2019-05-21T21:30:00.000Z" - }], - "upcoming_shows": [], - "past_shows_count": 1, - "upcoming_shows_count": 0, - } - data2={ - "id": 5, - "name": "Matt Quevedo", - "genres": ["Jazz"], - "city": "New York", - "state": "NY", - "phone": "300-400-5000", - "facebook_link": "https://www.facebook.com/mattquevedo923251523", - "seeking_venue": False, - "image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80", - "past_shows": [{ - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", - "start_time": "2019-06-15T23:00:00.000Z" - }], - "upcoming_shows": [], - "past_shows_count": 1, - "upcoming_shows_count": 0, - } - data3={ - "id": 6, - "name": "The Wild Sax Band", - "genres": ["Jazz", "Classical"], - "city": "San Francisco", - "state": "CA", - "phone": "432-325-5432", - "seeking_venue": False, - "image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", - "past_shows": [], - "upcoming_shows": [{ - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", - "start_time": "2035-04-01T20:00:00.000Z" - }, { - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", - "start_time": "2035-04-08T20:00:00.000Z" - }, { - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", - "start_time": "2035-04-15T20:00:00.000Z" - }], - "past_shows_count": 0, - "upcoming_shows_count": 3, - } - data = list(filter(lambda d: d['id'] == artist_id, [data1, data2, data3]))[0] - return render_template('pages/show_artist.html', artist=data) - -# Update -# ---------------------------------------------------------------- -@app.route('/artists//edit', methods=['GET']) -def edit_artist(artist_id): - form = ArtistForm() - artist={ - "id": 4, - "name": "Guns N Petals", - "genres": ["Rock n Roll"], - "city": "San Francisco", - "state": "CA", - "phone": "326-123-5000", - "website": "https://www.gunsnpetalsband.com", - "facebook_link": "https://www.facebook.com/GunsNPetals", - "seeking_venue": True, - "seeking_description": "Looking for shows to perform at in the San Francisco Bay Area!", - "image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80" - } - # TODO: populate form with fields from artist with ID - return render_template('forms/edit_artist.html', form=form, artist=artist) - -@app.route('/artists//edit', methods=['POST']) -def edit_artist_submission(artist_id): - # TODO: take values from the form submitted, and update existing - # artist record with ID using the new attributes - - return redirect(url_for('show_artist', artist_id=artist_id)) - -@app.route('/venues//edit', methods=['GET']) -def edit_venue(venue_id): - form = VenueForm() - venue={ - "id": 1, - "name": "The Musical Hop", - "genres": ["Jazz", "Reggae", "Swing", "Classical", "Folk"], - "address": "1015 Folsom Street", - "city": "San Francisco", - "state": "CA", - "phone": "123-123-1234", - "website": "https://www.themusicalhop.com", - "facebook_link": "https://www.facebook.com/TheMusicalHop", - "seeking_talent": True, - "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", - "image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60" - } - # TODO: populate form with values from venue with ID - return render_template('forms/edit_venue.html', form=form, venue=venue) - -@app.route('/venues//edit', methods=['POST']) -def edit_venue_submission(venue_id): - # TODO: take values from the form submitted, and update existing - # venue record with ID using the new attributes - return redirect(url_for('show_venue', venue_id=venue_id)) - -# Create Artist -# ---------------------------------------------------------------- - -@app.route('/artists/create', methods=['GET']) + try: + artist = db.session.query(Artist).filter(Artist.id == artist_id).one_or_none() + if not artist: + abort(404) + + return render_template('pages/show_artist.html', artist=artist.to_dict()) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() + + +@app.route('/artists/create', methods=['GET']) def create_artist_form(): form = ArtistForm() return render_template('forms/new_artist.html', form=form) + @app.route('/artists/create', methods=['POST']) def create_artist_submission(): - # called upon submitting the new artist listing form - # TODO: insert form data as a new Venue record in the db, instead - # TODO: modify data to be the data object returned from db insertion + form = ArtistForm(request.form, meta={'csrf': False}) + + if form.validate(): + name = form.name.data + try: + exists = db.session.query(Artist).filter(Artist.name == name).one_or_none() + if exists: + flash('This name is already in use.') + return redirect(url_for('create_artist_form')) + + new_artist = Artist(name=name, city=form.city.data, state=form.state.data, + phone=form.phone.data, image_link=form.image_link.data, + facebook_link=form.facebook_link.data, website=form.website_link.data, + seeking_venue=form.seeking_venue.data, + seeking_description=form.seeking_description.data, + genres=form.genres.data) + db.session.add(new_artist) + db.session.commit() + flash(f'Artist "{name}" was successfully listed!') + return redirect(url_for('show_artist', artist_id=new_artist.id)) + + except Exception as e: + app.logger.error(e) + flash(f'An error occurred. Artist "{name}" could not be listed.') + db.session.rollback() + return redirect(url_for('create_artist_form')) + + finally: + db.session.close() + else: + message = [] + for field, errors in form.errors.items(): + for err in errors: + message.append(f'{field}: {err}') + flash('Please fix the following errors: ' + ', '.join(message)) + return redirect(url_for('create_artist_form')) + - # on successful db insert, flash success - flash('Artist ' + request.form['name'] + ' was successfully listed!') - # TODO: on unsuccessful db insert, flash an error instead. - # e.g., flash('An error occurred. Artist ' + data.name + ' could not be listed.') - return render_template('pages/home.html') +@app.route('/artists//edit', methods=['GET']) +def edit_artist(artist_id): + try: + artist = db.session.query(Artist).filter(Artist.id == artist_id).one_or_none() + if not artist: + abort(404) + + form = ArtistForm(object=artist) + return render_template('forms/edit_artist.html', form=form, artist=artist) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() +@app.route('/artists//edit', methods=['POST']) +def edit_artist_submission(artist_id): + form = ArtistForm(request.form, meta={'csrf': False}) + artist = db.session.query(Artist).filter(Artist.id == artist_id).one_or_none() + + if form.validate(): + try: + artist.name = form.name.data + artist.city = form.city.data + artist.state = form.state.data + artist.phone = form.phone.data + artist.image_link = form.image_link.data + artist.facebook_link = form.facebook_link.data + artist.website = form.website_link.data + artist.seeking_venue = form.seeking_venue.data + artist.seeking_description = form.seeking_description.data + artist.genres = form.genres.data + + db.session.commit() + flash('Artist successfully updated!') + return redirect(url_for('show_artist', artist_id=artist_id)) + + except Exception as e: + app.logger.error(e) + flash('Unsuccessful update.') + db.session.rollback() + return redirect(url_for('edit_artist', artist_id=artist_id)) + + finally: + db.session.close() + + else: + message = [] + for field, errors in form.errors.items(): + for err in errors: + message.append(f'{field}: {err}') + flash('Please fix the following errors: ' + ', '.join(message)) + return redirect(url_for('edit_artst', artist_id=artist_id)) + + # Shows # ---------------------------------------------------------------- -@app.route('/shows') +@app.route('/shows', methods=['GET']) def shows(): - # displays list of shows at /shows - # TODO: replace with real venues data. - data=[{ - "venue_id": 1, - "venue_name": "The Musical Hop", - "artist_id": 4, - "artist_name": "Guns N Petals", - "artist_image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80", - "start_time": "2019-05-21T21:30:00.000Z" - }, { - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "artist_id": 5, - "artist_name": "Matt Quevedo", - "artist_image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80", - "start_time": "2019-06-15T23:00:00.000Z" - }, { - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "artist_id": 6, - "artist_name": "The Wild Sax Band", - "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", - "start_time": "2035-04-01T20:00:00.000Z" - }, { - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "artist_id": 6, - "artist_name": "The Wild Sax Band", - "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", - "start_time": "2035-04-08T20:00:00.000Z" - }, { - "venue_id": 3, - "venue_name": "Park Square Live Music & Coffee", - "artist_id": 6, - "artist_name": "The Wild Sax Band", - "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", - "start_time": "2035-04-15T20:00:00.000Z" - }] - return render_template('pages/shows.html', shows=data) - -@app.route('/shows/create') -def create_shows(): - # renders form. do not touch. - form = ShowForm() - return render_template('forms/new_show.html', form=form) + try: + shows = db.session.query(Show).all() + if not shows: + flash('No show(s) yet. Please create one.') + return redirect(url_for('create_show_form')) + + resp = [] + for show in shows: + venue = db.session.query(Venue).filter(Venue.id == show.venue_id).one_or_none() + artist = db.session.query(Artist).filter(Artist.id == show.artist_id).one_or_none() + resp.append({ + 'venue_id': show.venue_id, + 'venue_name': venue.name, + 'artist_id': show.artist_id, + 'artist_name': artist.name, + 'artist_image_link': artist.image_link, + 'start_time': show.start_time.isoformat(), + }) + return render_template('pages/shows.html', shows=resp) + + except: + abort(500) + + finally: + db.session.close() + + +@app.route('/shows/create', methods=['GET']) +def create_show_form(): + form = ShowForm() + return render_template('forms/new_show.html', form=form) + @app.route('/shows/create', methods=['POST']) def create_show_submission(): - # called to create new shows in the db, upon submitting new show listing form - # TODO: insert form data as a new Show record in the db, instead - - # on successful db insert, flash success - flash('Show was successfully listed!') - # TODO: on unsuccessful db insert, flash an error instead. - # e.g., flash('An error occurred. Show could not be listed.') - # see: http://flask.pocoo.org/docs/1.0/patterns/flashing/ - return render_template('pages/home.html') + form = ShowForm(request.form, meta={'csrf': False}) + + artist_id = form.artist_id.data + venue_id = form.venue_id.data + start_time = form.start_time.data + + if form.validate(): + try: + artist = db.session.query(Artist).filter(Artist.id == artist_id).one_or_none() + venue = db.session.query(Venue).filter(Venue.id == venue_id).one_or_none() + + if not artist: + flash('Cannot create new show with non-existent artist. Create the new artist first.') + return redirect(url_for('create_artist_form')) + + elif not venue: + flash('Cannot create new show with non-existent venue. Create the new venue first.') + return redirect(url_for('create_venue_form')) + + except Exception as e: + app.logger.error(e) + abort(500) + + finally: + db.session.close() + + try: + new_show = Show(venue_id=venue_id, artist_id=artist_id, start_time=start_time) + db.session.add(new_show) + db.session.commit() + flash('Show was successfully listed!') + return render_template('pages/home.html') + + except Exception as e: + db.session.rollback() + app.logger.error(e) + flash('An error occurred. Show could not be listed.') + return redirect(url_for('create_show_form')) + + finally: + db.session.close() + + else: + message = [] + for field, errors in form.errors.items(): + for err in errors: + message.append(f'{field}: {err}') + flash('Please fix the following errors: ' + ', '.join(message)) + return redirect(url_for('create_show_form')) + + +# Error handlers +# ---------------------------------------------------------------- @app.errorhandler(404) def not_found_error(error): return render_template('errors/404.html'), 404 + @app.errorhandler(500) def server_error(error): return render_template('errors/500.html'), 500 diff --git a/config.py b/config.py index c91475f47..ceefe08a8 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,10 @@ import os + +DB_USER = os.environ.get('DB_USER', 'postgres') +DB_PWD = os.environ.get('DB_PWD', 'postgres') +DB_HOST = os.environ.get('DB_HOST', 'localhost:5432') +DB_NAME = os.environ.get('DB_NAME', 'fyyur') + SECRET_KEY = os.urandom(32) # Grabs the folder where the script runs. basedir = os.path.abspath(os.path.dirname(__file__)) @@ -6,8 +12,6 @@ # Enable debug mode. DEBUG = True -# Connect to the database - - -# TODO IMPLEMENT DATABASE URL -SQLALCHEMY_DATABASE_URI = '' +SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}/{}'.format(DB_USER, DB_PWD, DB_HOST, DB_NAME) +SQLALCHEMY_TRACK_MODIFICATIONS = False +SQLALCHEMY_ECHO = True diff --git a/forms.py b/forms.py index ffd553b6e..4f77ecf90 100644 --- a/forms.py +++ b/forms.py @@ -1,14 +1,16 @@ from datetime import datetime -from flask_wtf import Form +from flask_wtf import FlaskForm as Form from wtforms import StringField, SelectField, SelectMultipleField, DateTimeField, BooleanField -from wtforms.validators import DataRequired, AnyOf, URL +from wtforms.validators import DataRequired, InputRequired, ValidationError +from validate import is_valid_phone + class ShowForm(Form): artist_id = StringField( - 'artist_id' + 'artist_id', validators=[InputRequired()] ) venue_id = StringField( - 'venue_id' + 'venue_id', validators=[InputRequired()] ) start_time = DateTimeField( 'start_time', @@ -18,7 +20,7 @@ class ShowForm(Form): class VenueForm(Form): name = StringField( - 'name', validators=[DataRequired()] + 'name', validators=[InputRequired()] ) city = StringField( 'city', validators=[DataRequired()] @@ -83,13 +85,12 @@ class VenueForm(Form): 'address', validators=[DataRequired()] ) phone = StringField( - 'phone' + 'phone', validators=[InputRequired()] ) image_link = StringField( 'image_link' ) genres = SelectMultipleField( - # TODO implement enum restriction 'genres', validators=[DataRequired()], choices=[ ('Alternative', 'Alternative'), @@ -114,23 +115,29 @@ class VenueForm(Form): ] ) facebook_link = StringField( - 'facebook_link', validators=[URL()] + 'facebook_link' ) website_link = StringField( 'website_link' ) - seeking_talent = BooleanField( 'seeking_talent' ) + seeking_talent = BooleanField('seeking_talent') seeking_description = StringField( 'seeking_description' ) + def validate_phone(self, field): + if not is_valid_phone(field.data): + raise ValidationError('Invalid phone.') + + def validate(self, **kwargs): + return super(VenueForm, self).validate(**kwargs) class ArtistForm(Form): name = StringField( - 'name', validators=[DataRequired()] + 'name', validators=[InputRequired()] ) city = StringField( 'city', validators=[DataRequired()] @@ -192,8 +199,7 @@ class ArtistForm(Form): ] ) phone = StringField( - # TODO implement validation logic for state - 'phone' + 'phone', validators=[InputRequired()] ) image_link = StringField( 'image_link' @@ -223,17 +229,22 @@ class ArtistForm(Form): ] ) facebook_link = StringField( - # TODO implement enum restriction - 'facebook_link', validators=[URL()] + 'facebook_link' ) website_link = StringField( 'website_link' ) - seeking_venue = BooleanField( 'seeking_venue' ) + seeking_venue = BooleanField('seeking_venue') seeking_description = StringField( 'seeking_description' ) + def validate_phone(self, field): + if not is_valid_phone(field.data): + raise ValidationError('Invalid phone.') + + def validate(self, **kwargs): + return super(ArtistForm, self).validate(**kwargs) diff --git a/model.py b/model.py new file mode 100644 index 000000000..e5a05c550 --- /dev/null +++ b/model.py @@ -0,0 +1,171 @@ +from datetime import datetime +from flask_sqlalchemy import SQLAlchemy + +db = SQLAlchemy() + + +class Artist(db.Model): + __tablename__ = 'artist' + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(120), nullable=False) + city = db.Column(db.String(120), nullable=False) + state = db.Column(db.String(120), nullable=False) + phone = db.Column(db.String(120), nullable=False) + image_link = db.Column( db.String(500), nullable=True) + facebook_link = db.Column(db.String(120), nullable=True) + website = db.Column(db.String(120), nullable=True) + seeking_venue = db.Column(db.Boolean, nullable=True, default=False) + seeking_description = db.Column(db.String(), nullable=True) + genres = db.Column(db.ARRAY(db.String(120)), nullable=False) + + shows = db.relationship('Show', backref='artist', lazy='joined', cascade='all, delete') + + @property + def past_shows(self): + results = [] + for show in self.shows: + if show.start_time < datetime.now(): + results.append(show) + + data = [] + for result in results: + venue = db.session.query(Venue).filter(Venue.id == result.venue_id).one_or_none() + data.append({ + 'venue_id': result.venue_id, + 'venue_name': venue.name, + 'venue_image_link': venue.image_link, + 'start_time': result.start_time.isoformat(), + }) + + return data + + @property + def upcoming_shows(self): + results = [] + for show in self.shows: + if show.start_time > datetime.now(): + results.append(show) + + data = [] + for result in results: + venue = db.session.query(Venue).filter(Venue.id == result.venue_id).one_or_none() + data.append({ + 'venue_id': result.venue_id, + 'venue_name': venue.name, + 'venue_image_link': venue.image_link, + 'start_time': result.start_time.isoformat(), + }) + + return data + + def to_dict(self): + return { + 'id': self.id, + 'name': self.name, + 'city': self.city, + 'state': self.state, + 'phone': self.phone, + 'image_link': self.image_link, + 'facebook_link': self.facebook_link, + 'website': self.website, + 'seeking_venue': self.seeking_venue, + 'seeking_description': self.seeking_description, + 'genres': self.genres, + 'past_shows': self.past_shows, + 'upcoming_shows': self.upcoming_shows, + 'past_shows_count': len(self.past_shows), + 'upcoming_shows_count': len(self.upcoming_shows), + } + + def __repr__(self): + return f'' + + +class Venue(db.Model): + __tablename__ = 'venue' + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String, nullable=False) + city = db.Column(db.String(120), nullable=False) + state = db.Column(db.String(120), nullable=False) + address = db.Column(db.String(120), nullable=False) + phone = db.Column(db.String(120), nullable=False) + image_link = db.Column(db.String(500), nullable=True) + facebook_link = db.Column(db.String(120), nullable=True) + website = db.Column(db.String(120), nullable=True) + seeking_talent = db.Column(db.Boolean, nullable=True, default=False) + seeking_description = db.Column(db.String(120), nullable=True) + genres = db.Column(db.ARRAY(db.String(120)), nullable=False) + + shows = db.relationship('Show', backref='venue', lazy='joined', cascade='all, delete') + + @property + def past_shows(self): + results = [] + for show in self.shows: + if show.start_time < datetime.now(): + results.append(show) + + data = [] + for result in results: + artist = db.session.query(Artist).filter(Artist.id == result.artist_id).one_or_none() + data.append({ + 'artist_id': result.artist_id, + 'artist_name': artist.name, + 'artist_image_link': artist.image_link, + 'start_time': result.start_time.strftime('%m/%d/%Y, %H:%M'), + }) + + return data + + @property + def upcoming_shows(self): + results = [] + for show in self.shows: + if show.start_time > datetime.now(): + results.append(show) + + data = [] + for result in results: + artist = db.session.query(Artist).filter(Artist.id == result.artist_id).one_or_none() + data.append({ + 'artist_id': result.artist_id, + 'artist_name': artist.name, + 'artist_image_link': artist.image_link, + 'start_time': result.start_time.strftime('%m/%d/%Y, %H:%M'), + }) + + return data + + def to_dict(self): + return { + 'id': self.id, + 'name': self.name, + 'city': self.city, + 'state': self.state, + 'phone': self.phone, + 'image_link': self.image_link, + 'facebook_link': self.facebook_link, + 'website': self.website, + 'seeking_talent': self.seeking_talent, + 'seeking_description': self.seeking_description, + 'genres': self.genres, + 'past_shows': self.past_shows, + 'upcoming_shows': self.upcoming_shows, + 'past_shows_count': len(self.past_shows), + 'upcoming_shows_count': len(self.upcoming_shows), + } + + def __repr__(self): + return f'' + + +class Show(db.Model): + __tablename__ = 'show' + id = db.Column(db.Integer, primary_key=True) + venue_id = db.Column(db.Integer, db.ForeignKey('venue.id'), nullable=False) + artist_id = db.Column(db.Integer, db.ForeignKey('artist.id'), nullable=False) + start_time = db.Column(db.DateTime, nullable=False) + + def __repr__(self): + return f'' + \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 000000000..8b7ed43a4 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,612 @@ +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. + +[[package]] +name = "alembic" +version = "1.11.3" +description = "A database migration tool for SQLAlchemy." +optional = false +python-versions = ">=3.7" +files = [ + {file = "alembic-1.11.3-py3-none-any.whl", hash = "sha256:d6c96c2482740592777c400550a523bc7a9aada4e210cae2e733354ddae6f6f8"}, + {file = "alembic-1.11.3.tar.gz", hash = "sha256:3db4ce81a9072e1b5aa44c2d202add24553182672a12daf21608d6f62a8f9cf9"}, +] + +[package.dependencies] +Mako = "*" +SQLAlchemy = ">=1.3.0" +typing-extensions = ">=4" + +[package.extras] +tz = ["python-dateutil"] + +[[package]] +name = "babel" +version = "2.12.1" +description = "Internationalization utilities" +optional = false +python-versions = ">=3.7" +files = [ + {file = "Babel-2.12.1-py3-none-any.whl", hash = "sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610"}, + {file = "Babel-2.12.1.tar.gz", hash = "sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455"}, +] + +[[package]] +name = "blinker" +version = "1.6.2" +description = "Fast, simple object-to-object and broadcast signaling" +optional = false +python-versions = ">=3.7" +files = [ + {file = "blinker-1.6.2-py3-none-any.whl", hash = "sha256:c3d739772abb7bc2860abf5f2ec284223d9ad5c76da018234f6f50d6f31ab1f0"}, + {file = "blinker-1.6.2.tar.gz", hash = "sha256:4afd3de66ef3a9f8067559fb7a1cbe555c17dcbe15971b05d1b625c3e7abe213"}, +] + +[[package]] +name = "click" +version = "8.1.7" +description = "Composable command line interface toolkit" +optional = false +python-versions = ">=3.7" +files = [ + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "flask" +version = "2.3.3" +description = "A simple framework for building complex web applications." +optional = false +python-versions = ">=3.8" +files = [ + {file = "flask-2.3.3-py3-none-any.whl", hash = "sha256:f69fcd559dc907ed196ab9df0e48471709175e696d6e698dd4dbe940f96ce66b"}, + {file = "flask-2.3.3.tar.gz", hash = "sha256:09c347a92aa7ff4a8e7f3206795f30d826654baf38b873d0744cd571ca609efc"}, +] + +[package.dependencies] +blinker = ">=1.6.2" +click = ">=8.1.3" +importlib-metadata = {version = ">=3.6.0", markers = "python_version < \"3.10\""} +itsdangerous = ">=2.1.2" +Jinja2 = ">=3.1.2" +Werkzeug = ">=2.3.7" + +[package.extras] +async = ["asgiref (>=3.2)"] +dotenv = ["python-dotenv"] + +[[package]] +name = "flask-migrate" +version = "4.0.4" +description = "SQLAlchemy database migrations for Flask applications using Alembic." +optional = false +python-versions = ">=3.6" +files = [ + {file = "Flask-Migrate-4.0.4.tar.gz", hash = "sha256:73293d40b10ac17736e715b377e7b7bde474cb8105165d77474df4c3619b10b3"}, + {file = "Flask_Migrate-4.0.4-py3-none-any.whl", hash = "sha256:77580f27ab39bc68be4906a43c56d7674b45075bc4f883b1d0b985db5164d58f"}, +] + +[package.dependencies] +alembic = ">=1.9.0" +Flask = ">=0.9" +Flask-SQLAlchemy = ">=1.0" + +[[package]] +name = "flask-moment" +version = "1.0.5" +description = "Formatting of dates and times in Flask templates using moment.js." +optional = false +python-versions = ">=3.6" +files = [ + {file = "Flask-Moment-1.0.5.tar.gz", hash = "sha256:33307ecd4af8290b6df6a9828ff55ac0977d0567817f9bc0f69803d22ed2b55c"}, + {file = "Flask_Moment-1.0.5-py3-none-any.whl", hash = "sha256:6e7b3eef89e2137bbbee975405f241a68a44edfa34bf052c92d84364992adca6"}, +] + +[package.dependencies] +Flask = "*" +packaging = ">=14.1" + +[[package]] +name = "flask-sqlalchemy" +version = "3.0.5" +description = "Add SQLAlchemy support to your Flask application." +optional = false +python-versions = ">=3.7" +files = [ + {file = "flask_sqlalchemy-3.0.5-py3-none-any.whl", hash = "sha256:cabb6600ddd819a9f859f36515bb1bd8e7dbf30206cc679d2b081dff9e383283"}, + {file = "flask_sqlalchemy-3.0.5.tar.gz", hash = "sha256:c5765e58ca145401b52106c0f46178569243c5da25556be2c231ecc60867c5b1"}, +] + +[package.dependencies] +flask = ">=2.2.5" +sqlalchemy = ">=1.4.18" + +[[package]] +name = "flask-wtf" +version = "1.1.1" +description = "Form rendering, validation, and CSRF protection for Flask with WTForms." +optional = false +python-versions = ">=3.7" +files = [ + {file = "Flask-WTF-1.1.1.tar.gz", hash = "sha256:41c4244e9ae626d63bed42ae4785b90667b885b1535d5a4095e1f63060d12aa9"}, + {file = "Flask_WTF-1.1.1-py3-none-any.whl", hash = "sha256:7887d6f1ebb3e17bf648647422f0944c9a469d0fcf63e3b66fb9a83037e38b2c"}, +] + +[package.dependencies] +Flask = "*" +itsdangerous = "*" +WTForms = "*" + +[package.extras] +email = ["email-validator"] + +[[package]] +name = "greenlet" +version = "2.0.2" +description = "Lightweight in-process concurrent programming" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" +files = [ + {file = "greenlet-2.0.2-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:bdfea8c661e80d3c1c99ad7c3ff74e6e87184895bbaca6ee8cc61209f8b9b85d"}, + {file = "greenlet-2.0.2-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:9d14b83fab60d5e8abe587d51c75b252bcc21683f24699ada8fb275d7712f5a9"}, + {file = "greenlet-2.0.2-cp27-cp27m-win32.whl", hash = "sha256:6c3acb79b0bfd4fe733dff8bc62695283b57949ebcca05ae5c129eb606ff2d74"}, + {file = "greenlet-2.0.2-cp27-cp27m-win_amd64.whl", hash = "sha256:283737e0da3f08bd637b5ad058507e578dd462db259f7f6e4c5c365ba4ee9343"}, + {file = "greenlet-2.0.2-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:d27ec7509b9c18b6d73f2f5ede2622441de812e7b1a80bbd446cb0633bd3d5ae"}, + {file = "greenlet-2.0.2-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:30bcf80dda7f15ac77ba5af2b961bdd9dbc77fd4ac6105cee85b0d0a5fcf74df"}, + {file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26fbfce90728d82bc9e6c38ea4d038cba20b7faf8a0ca53a9c07b67318d46088"}, + {file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9190f09060ea4debddd24665d6804b995a9c122ef5917ab26e1566dcc712ceeb"}, + {file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d75209eed723105f9596807495d58d10b3470fa6732dd6756595e89925ce2470"}, + {file = "greenlet-2.0.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:3a51c9751078733d88e013587b108f1b7a1fb106d402fb390740f002b6f6551a"}, + {file = "greenlet-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:76ae285c8104046b3a7f06b42f29c7b73f77683df18c49ab5af7983994c2dd91"}, + {file = "greenlet-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:2d4686f195e32d36b4d7cf2d166857dbd0ee9f3d20ae349b6bf8afc8485b3645"}, + {file = "greenlet-2.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c4302695ad8027363e96311df24ee28978162cdcdd2006476c43970b384a244c"}, + {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c48f54ef8e05f04d6eff74b8233f6063cb1ed960243eacc474ee73a2ea8573ca"}, + {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a1846f1b999e78e13837c93c778dcfc3365902cfb8d1bdb7dd73ead37059f0d0"}, + {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a06ad5312349fec0ab944664b01d26f8d1f05009566339ac6f63f56589bc1a2"}, + {file = "greenlet-2.0.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:eff4eb9b7eb3e4d0cae3d28c283dc16d9bed6b193c2e1ace3ed86ce48ea8df19"}, + {file = "greenlet-2.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5454276c07d27a740c5892f4907c86327b632127dd9abec42ee62e12427ff7e3"}, + {file = "greenlet-2.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:7cafd1208fdbe93b67c7086876f061f660cfddc44f404279c1585bbf3cdc64c5"}, + {file = "greenlet-2.0.2-cp35-cp35m-macosx_10_14_x86_64.whl", hash = "sha256:910841381caba4f744a44bf81bfd573c94e10b3045ee00de0cbf436fe50673a6"}, + {file = "greenlet-2.0.2-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:18a7f18b82b52ee85322d7a7874e676f34ab319b9f8cce5de06067384aa8ff43"}, + {file = "greenlet-2.0.2-cp35-cp35m-win32.whl", hash = "sha256:03a8f4f3430c3b3ff8d10a2a86028c660355ab637cee9333d63d66b56f09d52a"}, + {file = "greenlet-2.0.2-cp35-cp35m-win_amd64.whl", hash = "sha256:4b58adb399c4d61d912c4c331984d60eb66565175cdf4a34792cd9600f21b394"}, + {file = "greenlet-2.0.2-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:703f18f3fda276b9a916f0934d2fb6d989bf0b4fb5a64825260eb9bfd52d78f0"}, + {file = "greenlet-2.0.2-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:32e5b64b148966d9cccc2c8d35a671409e45f195864560829f395a54226408d3"}, + {file = "greenlet-2.0.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2dd11f291565a81d71dab10b7033395b7a3a5456e637cf997a6f33ebdf06f8db"}, + {file = "greenlet-2.0.2-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e0f72c9ddb8cd28532185f54cc1453f2c16fb417a08b53a855c4e6a418edd099"}, + {file = "greenlet-2.0.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cd021c754b162c0fb55ad5d6b9d960db667faad0fa2ff25bb6e1301b0b6e6a75"}, + {file = "greenlet-2.0.2-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:3c9b12575734155d0c09d6c3e10dbd81665d5c18e1a7c6597df72fd05990c8cf"}, + {file = "greenlet-2.0.2-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:b9ec052b06a0524f0e35bd8790686a1da006bd911dd1ef7d50b77bfbad74e292"}, + {file = "greenlet-2.0.2-cp36-cp36m-win32.whl", hash = "sha256:dbfcfc0218093a19c252ca8eb9aee3d29cfdcb586df21049b9d777fd32c14fd9"}, + {file = "greenlet-2.0.2-cp36-cp36m-win_amd64.whl", hash = "sha256:9f35ec95538f50292f6d8f2c9c9f8a3c6540bbfec21c9e5b4b751e0a7c20864f"}, + {file = "greenlet-2.0.2-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:d5508f0b173e6aa47273bdc0a0b5ba055b59662ba7c7ee5119528f466585526b"}, + {file = "greenlet-2.0.2-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:f82d4d717d8ef19188687aa32b8363e96062911e63ba22a0cff7802a8e58e5f1"}, + {file = "greenlet-2.0.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9c59a2120b55788e800d82dfa99b9e156ff8f2227f07c5e3012a45a399620b7"}, + {file = "greenlet-2.0.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2780572ec463d44c1d3ae850239508dbeb9fed38e294c68d19a24d925d9223ca"}, + {file = "greenlet-2.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:937e9020b514ceedb9c830c55d5c9872abc90f4b5862f89c0887033ae33c6f73"}, + {file = "greenlet-2.0.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:36abbf031e1c0f79dd5d596bfaf8e921c41df2bdf54ee1eed921ce1f52999a86"}, + {file = "greenlet-2.0.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:18e98fb3de7dba1c0a852731c3070cf022d14f0d68b4c87a19cc1016f3bb8b33"}, + {file = "greenlet-2.0.2-cp37-cp37m-win32.whl", hash = "sha256:3f6ea9bd35eb450837a3d80e77b517ea5bc56b4647f5502cd28de13675ee12f7"}, + {file = "greenlet-2.0.2-cp37-cp37m-win_amd64.whl", hash = "sha256:7492e2b7bd7c9b9916388d9df23fa49d9b88ac0640db0a5b4ecc2b653bf451e3"}, + {file = "greenlet-2.0.2-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:b864ba53912b6c3ab6bcb2beb19f19edd01a6bfcbdfe1f37ddd1778abfe75a30"}, + {file = "greenlet-2.0.2-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:ba2956617f1c42598a308a84c6cf021a90ff3862eddafd20c3333d50f0edb45b"}, + {file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc3a569657468b6f3fb60587e48356fe512c1754ca05a564f11366ac9e306526"}, + {file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8eab883b3b2a38cc1e050819ef06a7e6344d4a990d24d45bc6f2cf959045a45b"}, + {file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:acd2162a36d3de67ee896c43effcd5ee3de247eb00354db411feb025aa319857"}, + {file = "greenlet-2.0.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:0bf60faf0bc2468089bdc5edd10555bab6e85152191df713e2ab1fcc86382b5a"}, + {file = "greenlet-2.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b0ef99cdbe2b682b9ccbb964743a6aca37905fda5e0452e5ee239b1654d37f2a"}, + {file = "greenlet-2.0.2-cp38-cp38-win32.whl", hash = "sha256:b80f600eddddce72320dbbc8e3784d16bd3fb7b517e82476d8da921f27d4b249"}, + {file = "greenlet-2.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:4d2e11331fc0c02b6e84b0d28ece3a36e0548ee1a1ce9ddde03752d9b79bba40"}, + {file = "greenlet-2.0.2-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:88d9ab96491d38a5ab7c56dd7a3cc37d83336ecc564e4e8816dbed12e5aaefc8"}, + {file = "greenlet-2.0.2-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:561091a7be172ab497a3527602d467e2b3fbe75f9e783d8b8ce403fa414f71a6"}, + {file = "greenlet-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:971ce5e14dc5e73715755d0ca2975ac88cfdaefcaab078a284fea6cfabf866df"}, + {file = "greenlet-2.0.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be4ed120b52ae4d974aa40215fcdfde9194d63541c7ded40ee12eb4dda57b76b"}, + {file = "greenlet-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94c817e84245513926588caf1152e3b559ff794d505555211ca041f032abbb6b"}, + {file = "greenlet-2.0.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:1a819eef4b0e0b96bb0d98d797bef17dc1b4a10e8d7446be32d1da33e095dbb8"}, + {file = "greenlet-2.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:7efde645ca1cc441d6dc4b48c0f7101e8d86b54c8530141b09fd31cef5149ec9"}, + {file = "greenlet-2.0.2-cp39-cp39-win32.whl", hash = "sha256:ea9872c80c132f4663822dd2a08d404073a5a9b5ba6155bea72fb2a79d1093b5"}, + {file = "greenlet-2.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:db1a39669102a1d8d12b57de2bb7e2ec9066a6f2b3da35ae511ff93b01b5d564"}, + {file = "greenlet-2.0.2.tar.gz", hash = "sha256:e7c8dc13af7db097bed64a051d2dd49e9f0af495c26995c00a9ee842690d34c0"}, +] + +[package.extras] +docs = ["Sphinx", "docutils (<0.18)"] +test = ["objgraph", "psutil"] + +[[package]] +name = "importlib-metadata" +version = "6.8.0" +description = "Read metadata from Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "importlib_metadata-6.8.0-py3-none-any.whl", hash = "sha256:3ebb78df84a805d7698245025b975d9d67053cd94c79245ba4b3eb694abe68bb"}, + {file = "importlib_metadata-6.8.0.tar.gz", hash = "sha256:dbace7892d8c0c4ac1ad096662232f831d4e64f4c4545bd53016a3e9d4654743"}, +] + +[package.dependencies] +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] + +[[package]] +name = "itsdangerous" +version = "2.1.2" +description = "Safely pass data to untrusted environments and back." +optional = false +python-versions = ">=3.7" +files = [ + {file = "itsdangerous-2.1.2-py3-none-any.whl", hash = "sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44"}, + {file = "itsdangerous-2.1.2.tar.gz", hash = "sha256:5dbbc68b317e5e42f327f9021763545dc3fc3bfe22e6deb96aaf1fc38874156a"}, +] + +[[package]] +name = "jinja2" +version = "3.1.2" +description = "A very fast and expressive template engine." +optional = false +python-versions = ">=3.7" +files = [ + {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, + {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, +] + +[package.dependencies] +MarkupSafe = ">=2.0" + +[package.extras] +i18n = ["Babel (>=2.7)"] + +[[package]] +name = "mako" +version = "1.2.4" +description = "A super-fast templating language that borrows the best ideas from the existing templating languages." +optional = false +python-versions = ">=3.7" +files = [ + {file = "Mako-1.2.4-py3-none-any.whl", hash = "sha256:c97c79c018b9165ac9922ae4f32da095ffd3c4e6872b45eded42926deea46818"}, + {file = "Mako-1.2.4.tar.gz", hash = "sha256:d60a3903dc3bb01a18ad6a89cdbe2e4eadc69c0bc8ef1e3773ba53d44c3f7a34"}, +] + +[package.dependencies] +MarkupSafe = ">=0.9.2" + +[package.extras] +babel = ["Babel"] +lingua = ["lingua"] +testing = ["pytest"] + +[[package]] +name = "markupsafe" +version = "2.1.3" +description = "Safely add untrusted strings to HTML/XML markup." +optional = false +python-versions = ">=3.7" +files = [ + {file = "MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:cd0f502fe016460680cd20aaa5a76d241d6f35a1c3350c474bac1273803893fa"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e09031c87a1e51556fdcb46e5bd4f59dfb743061cf93c4d6831bf894f125eb57"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:68e78619a61ecf91e76aa3e6e8e33fc4894a2bebe93410754bd28fce0a8a4f9f"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c1a9bcdadc6c28eecee2c119465aebff8f7a584dd719facdd9e825ec61ab52"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:525808b8019e36eb524b8c68acdd63a37e75714eac50e988180b169d64480a00"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:aa7bd130efab1c280bed0f45501b7c8795f9fdbeb02e965371bbef3523627779"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c9c804664ebe8f83a211cace637506669e7890fec1b4195b505c214e50dd4eb7"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-win32.whl", hash = "sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431"}, + {file = "MarkupSafe-2.1.3-cp310-cp310-win_amd64.whl", hash = "sha256:1577735524cdad32f9f694208aa75e422adba74f1baee7551620e43a3141f559"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3c0fae6c3be832a0a0473ac912810b2877c8cb9d76ca48de1ed31e1c68386575"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bfce63a9e7834b12b87c64d6b155fdd9b3b96191b6bd334bf37db7ff1fe457f2"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:338ae27d6b8745585f87218a3f23f1512dbf52c26c28e322dbe54bcede54ccb9"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e4dd52d80b8c83fdce44e12478ad2e85c64ea965e75d66dbeafb0a3e77308fcc"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:df0be2b576a7abbf737b1575f048c23fb1d769f267ec4358296f31c2479db8f9"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, + {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca379055a47383d02a5400cb0d110cef0a776fc644cda797db0c5696cfd7e18e"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:b7ff0f54cb4ff66dd38bebd335a38e2c22c41a8ee45aa608efc890ac3e3931bc"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:c011a4149cfbcf9f03994ec2edffcb8b1dc2d2aede7ca243746df97a5d41ce48"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:56d9f2ecac662ca1611d183feb03a3fa4406469dafe241673d521dd5ae92a155"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-win32.whl", hash = "sha256:8758846a7e80910096950b67071243da3e5a20ed2546e6392603c096778d48e0"}, + {file = "MarkupSafe-2.1.3-cp37-cp37m-win_amd64.whl", hash = "sha256:787003c0ddb00500e49a10f2844fac87aa6ce977b90b0feaaf9de23c22508b24"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:2ef12179d3a291be237280175b542c07a36e7f60718296278d8593d21ca937d4"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2c1b19b3aaacc6e57b7e25710ff571c24d6c3613a45e905b1fde04d691b98ee0"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8afafd99945ead6e075b973fefa56379c5b5c53fd8937dad92c662da5d8fd5ee"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c41976a29d078bb235fea9b2ecd3da465df42a562910f9022f1a03107bd02be"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d080e0a5eb2529460b30190fcfcc4199bd7f827663f858a226a81bc27beaa97e"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:504b320cd4b7eff6f968eddf81127112db685e81f7e36e75f9f84f0df46041c3"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:42de32b22b6b804f42c5d98be4f7e5e977ecdd9ee9b660fda1a3edf03b11792d"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-win32.whl", hash = "sha256:ceb01949af7121f9fc39f7d27f91be8546f3fb112c608bc4029aef0bab86a2a5"}, + {file = "MarkupSafe-2.1.3-cp38-cp38-win_amd64.whl", hash = "sha256:1b40069d487e7edb2676d3fbdb2b0829ffa2cd63a2ec26c4938b2d34391b4ecc"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8023faf4e01efadfa183e863fefde0046de576c6f14659e8782065bcece22198"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6b2b56950d93e41f33b4223ead100ea0fe11f8e6ee5f641eb753ce4b77a7042b"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9dcdfd0eaf283af041973bff14a2e143b8bd64e069f4c383416ecd79a81aab58"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:282c2cb35b5b673bbcadb33a585408104df04f14b2d9b01d4c345a3b92861c2c"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ab4a0df41e7c16a1392727727e7998a467472d0ad65f3ad5e6e765015df08636"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:7ef3cb2ebbf91e330e3bb937efada0edd9003683db6b57bb108c4001f37a02ea"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-win32.whl", hash = "sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2"}, + {file = "MarkupSafe-2.1.3-cp39-cp39-win_amd64.whl", hash = "sha256:3fd4abcb888d15a94f32b75d8fd18ee162ca0c064f35b11134be77050296d6ba"}, + {file = "MarkupSafe-2.1.3.tar.gz", hash = "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad"}, +] + +[[package]] +name = "packaging" +version = "23.1" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"}, + {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, +] + +[[package]] +name = "psycopg2-binary" +version = "2.9.7" +description = "psycopg2 - Python-PostgreSQL Database Adapter" +optional = false +python-versions = ">=3.6" +files = [ + {file = "psycopg2-binary-2.9.7.tar.gz", hash = "sha256:1b918f64a51ffe19cd2e230b3240ba481330ce1d4b7875ae67305bd1d37b041c"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ea5f8ee87f1eddc818fc04649d952c526db4426d26bab16efbe5a0c52b27d6ab"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2993ccb2b7e80844d534e55e0f12534c2871952f78e0da33c35e648bf002bbff"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dbbc3c5d15ed76b0d9db7753c0db40899136ecfe97d50cbde918f630c5eb857a"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:692df8763b71d42eb8343f54091368f6f6c9cfc56dc391858cdb3c3ef1e3e584"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9dcfd5d37e027ec393a303cc0a216be564b96c80ba532f3d1e0d2b5e5e4b1e6e"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17cc17a70dfb295a240db7f65b6d8153c3d81efb145d76da1e4a096e9c5c0e63"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e5666632ba2b0d9757b38fc17337d84bdf932d38563c5234f5f8c54fd01349c9"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:7db7b9b701974c96a88997d458b38ccb110eba8f805d4b4f74944aac48639b42"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:c82986635a16fb1fa15cd5436035c88bc65c3d5ced1cfaac7f357ee9e9deddd4"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4fe13712357d802080cfccbf8c6266a3121dc0e27e2144819029095ccf708372"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-win32.whl", hash = "sha256:122641b7fab18ef76b18860dd0c772290566b6fb30cc08e923ad73d17461dc63"}, + {file = "psycopg2_binary-2.9.7-cp310-cp310-win_amd64.whl", hash = "sha256:f8651cf1f144f9ee0fa7d1a1df61a9184ab72962531ca99f077bbdcba3947c58"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4ecc15666f16f97709106d87284c136cdc82647e1c3f8392a672616aed3c7151"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3fbb1184c7e9d28d67671992970718c05af5f77fc88e26fd7136613c4ece1f89"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8a7968fd20bd550431837656872c19575b687f3f6f98120046228e451e4064df"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:094af2e77a1976efd4956a031028774b827029729725e136514aae3cdf49b87b"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:26484e913d472ecb6b45937ea55ce29c57c662066d222fb0fbdc1fab457f18c5"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f309b77a7c716e6ed9891b9b42953c3ff7d533dc548c1e33fddc73d2f5e21f9"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6d92e139ca388ccfe8c04aacc163756e55ba4c623c6ba13d5d1595ed97523e4b"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:2df562bb2e4e00ee064779902d721223cfa9f8f58e7e52318c97d139cf7f012d"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:4eec5d36dbcfc076caab61a2114c12094c0b7027d57e9e4387b634e8ab36fd44"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1011eeb0c51e5b9ea1016f0f45fa23aca63966a4c0afcf0340ccabe85a9f65bd"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-win32.whl", hash = "sha256:ded8e15f7550db9e75c60b3d9fcbc7737fea258a0f10032cdb7edc26c2a671fd"}, + {file = "psycopg2_binary-2.9.7-cp311-cp311-win_amd64.whl", hash = "sha256:8a136c8aaf6615653450817a7abe0fc01e4ea720ae41dfb2823eccae4b9062a3"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2dec5a75a3a5d42b120e88e6ed3e3b37b46459202bb8e36cd67591b6e5feebc1"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc10da7e7df3380426521e8c1ed975d22df678639da2ed0ec3244c3dc2ab54c8"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ee919b676da28f78f91b464fb3e12238bd7474483352a59c8a16c39dfc59f0c5"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eb1c0e682138f9067a58fc3c9a9bf1c83d8e08cfbee380d858e63196466d5c86"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:00d8db270afb76f48a499f7bb8fa70297e66da67288471ca873db88382850bf4"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:9b0c2b466b2f4d89ccc33784c4ebb1627989bd84a39b79092e560e937a11d4ac"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:51d1b42d44f4ffb93188f9b39e6d1c82aa758fdb8d9de65e1ddfe7a7d250d7ad"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:11abdbfc6f7f7dea4a524b5f4117369b0d757725798f1593796be6ece20266cb"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:f02f4a72cc3ab2565c6d9720f0343cb840fb2dc01a2e9ecb8bc58ccf95dc5c06"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-win32.whl", hash = "sha256:81d5dd2dd9ab78d31a451e357315f201d976c131ca7d43870a0e8063b6b7a1ec"}, + {file = "psycopg2_binary-2.9.7-cp37-cp37m-win_amd64.whl", hash = "sha256:62cb6de84d7767164a87ca97e22e5e0a134856ebcb08f21b621c6125baf61f16"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:59f7e9109a59dfa31efa022e94a244736ae401526682de504e87bd11ce870c22"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:95a7a747bdc3b010bb6a980f053233e7610276d55f3ca506afff4ad7749ab58a"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c721ee464e45ecf609ff8c0a555018764974114f671815a0a7152aedb9f3343"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f4f37bbc6588d402980ffbd1f3338c871368fb4b1cfa091debe13c68bb3852b3"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ac83ab05e25354dad798401babaa6daa9577462136ba215694865394840e31f8"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:024eaeb2a08c9a65cd5f94b31ace1ee3bb3f978cd4d079406aef85169ba01f08"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:1c31c2606ac500dbd26381145684d87730a2fac9a62ebcfbaa2b119f8d6c19f4"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:42a62ef0e5abb55bf6ffb050eb2b0fcd767261fa3faf943a4267539168807522"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:7952807f95c8eba6a8ccb14e00bf170bb700cafcec3924d565235dffc7dc4ae8"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e02bc4f2966475a7393bd0f098e1165d470d3fa816264054359ed4f10f6914ea"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-win32.whl", hash = "sha256:fdca0511458d26cf39b827a663d7d87db6f32b93efc22442a742035728603d5f"}, + {file = "psycopg2_binary-2.9.7-cp38-cp38-win_amd64.whl", hash = "sha256:d0b16e5bb0ab78583f0ed7ab16378a0f8a89a27256bb5560402749dbe8a164d7"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6822c9c63308d650db201ba22fe6648bd6786ca6d14fdaf273b17e15608d0852"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8f94cb12150d57ea433e3e02aabd072205648e86f1d5a0a692d60242f7809b15"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5ee89587696d808c9a00876065d725d4ae606f5f7853b961cdbc348b0f7c9a1"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ad5ec10b53cbb57e9a2e77b67e4e4368df56b54d6b00cc86398578f1c635f329"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:642df77484b2dcaf87d4237792246d8068653f9e0f5c025e2c692fc56b0dda70"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a6a8b575ac45af1eaccbbcdcf710ab984fd50af048fe130672377f78aaff6fc1"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:f955aa50d7d5220fcb6e38f69ea126eafecd812d96aeed5d5f3597f33fad43bb"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:ad26d4eeaa0d722b25814cce97335ecf1b707630258f14ac4d2ed3d1d8415265"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:ced63c054bdaf0298f62681d5dcae3afe60cbae332390bfb1acf0e23dcd25fc8"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:2b04da24cbde33292ad34a40db9832a80ad12de26486ffeda883413c9e1b1d5e"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-win32.whl", hash = "sha256:18f12632ab516c47c1ac4841a78fddea6508a8284c7cf0f292cb1a523f2e2379"}, + {file = "psycopg2_binary-2.9.7-cp39-cp39-win_amd64.whl", hash = "sha256:eb3b8d55924a6058a26db69fb1d3e7e32695ff8b491835ba9f479537e14dcf9f"}, +] + +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "pytz" +version = "2023.3" +description = "World timezone definitions, modern and historical" +optional = false +python-versions = "*" +files = [ + {file = "pytz-2023.3-py2.py3-none-any.whl", hash = "sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb"}, + {file = "pytz-2023.3.tar.gz", hash = "sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588"}, +] + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + +[[package]] +name = "sqlalchemy" +version = "2.0.20" +description = "Database Abstraction Library" +optional = false +python-versions = ">=3.7" +files = [ + {file = "SQLAlchemy-2.0.20-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:759b51346aa388c2e606ee206c0bc6f15a5299f6174d1e10cadbe4530d3c7a98"}, + {file = "SQLAlchemy-2.0.20-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1506e988ebeaaf316f183da601f24eedd7452e163010ea63dbe52dc91c7fc70e"}, + {file = "SQLAlchemy-2.0.20-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5768c268df78bacbde166b48be788b83dddaa2a5974b8810af422ddfe68a9bc8"}, + {file = "SQLAlchemy-2.0.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a3f0dd6d15b6dc8b28a838a5c48ced7455c3e1fb47b89da9c79cc2090b072a50"}, + {file = "SQLAlchemy-2.0.20-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:243d0fb261f80a26774829bc2cee71df3222587ac789b7eaf6555c5b15651eed"}, + {file = "SQLAlchemy-2.0.20-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:6eb6d77c31e1bf4268b4d61b549c341cbff9842f8e115ba6904249c20cb78a61"}, + {file = "SQLAlchemy-2.0.20-cp310-cp310-win32.whl", hash = "sha256:bcb04441f370cbe6e37c2b8d79e4af9e4789f626c595899d94abebe8b38f9a4d"}, + {file = "SQLAlchemy-2.0.20-cp310-cp310-win_amd64.whl", hash = "sha256:d32b5ffef6c5bcb452723a496bad2d4c52b346240c59b3e6dba279f6dcc06c14"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dd81466bdbc82b060c3c110b2937ab65ace41dfa7b18681fdfad2f37f27acdd7"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6fe7d61dc71119e21ddb0094ee994418c12f68c61b3d263ebaae50ea8399c4d4"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e4e571af672e1bb710b3cc1a9794b55bce1eae5aed41a608c0401885e3491179"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3364b7066b3c7f4437dd345d47271f1251e0cfb0aba67e785343cdbdb0fff08c"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:1be86ccea0c965a1e8cd6ccf6884b924c319fcc85765f16c69f1ae7148eba64b"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1d35d49a972649b5080557c603110620a86aa11db350d7a7cb0f0a3f611948a0"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-win32.whl", hash = "sha256:27d554ef5d12501898d88d255c54eef8414576f34672e02fe96d75908993cf53"}, + {file = "SQLAlchemy-2.0.20-cp311-cp311-win_amd64.whl", hash = "sha256:411e7f140200c02c4b953b3dbd08351c9f9818d2bd591b56d0fa0716bd014f1e"}, + {file = "SQLAlchemy-2.0.20-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3c6aceebbc47db04f2d779db03afeaa2c73ea3f8dcd3987eb9efdb987ffa09a3"}, + {file = "SQLAlchemy-2.0.20-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7d3f175410a6db0ad96b10bfbb0a5530ecd4fcf1e2b5d83d968dd64791f810ed"}, + {file = "SQLAlchemy-2.0.20-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ea8186be85da6587456c9ddc7bf480ebad1a0e6dcbad3967c4821233a4d4df57"}, + {file = "SQLAlchemy-2.0.20-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c3d99ba99007dab8233f635c32b5cd24fb1df8d64e17bc7df136cedbea427897"}, + {file = "SQLAlchemy-2.0.20-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:76fdfc0f6f5341987474ff48e7a66c3cd2b8a71ddda01fa82fedb180b961630a"}, + {file = "SQLAlchemy-2.0.20-cp37-cp37m-win32.whl", hash = "sha256:d3793dcf5bc4d74ae1e9db15121250c2da476e1af8e45a1d9a52b1513a393459"}, + {file = "SQLAlchemy-2.0.20-cp37-cp37m-win_amd64.whl", hash = "sha256:79fde625a0a55220d3624e64101ed68a059c1c1f126c74f08a42097a72ff66a9"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:599ccd23a7146e126be1c7632d1d47847fa9f333104d03325c4e15440fc7d927"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:1a58052b5a93425f656675673ef1f7e005a3b72e3f2c91b8acca1b27ccadf5f4"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79543f945be7a5ada9943d555cf9b1531cfea49241809dd1183701f94a748624"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63e73da7fb030ae0a46a9ffbeef7e892f5def4baf8064786d040d45c1d6d1dc5"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:3ce5e81b800a8afc870bb8e0a275d81957e16f8c4b62415a7b386f29a0cb9763"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:cb0d3e94c2a84215532d9bcf10229476ffd3b08f481c53754113b794afb62d14"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-win32.whl", hash = "sha256:8dd77fd6648b677d7742d2c3cc105a66e2681cc5e5fb247b88c7a7b78351cf74"}, + {file = "SQLAlchemy-2.0.20-cp38-cp38-win_amd64.whl", hash = "sha256:6f8a934f9dfdf762c844e5164046a9cea25fabbc9ec865c023fe7f300f11ca4a"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:26a3399eaf65e9ab2690c07bd5cf898b639e76903e0abad096cd609233ce5208"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4cde2e1096cbb3e62002efdb7050113aa5f01718035ba9f29f9d89c3758e7e4e"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d1b09ba72e4e6d341bb5bdd3564f1cea6095d4c3632e45dc69375a1dbe4e26ec"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1b74eeafaa11372627ce94e4dc88a6751b2b4d263015b3523e2b1e57291102f0"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:77d37c1b4e64c926fa3de23e8244b964aab92963d0f74d98cbc0783a9e04f501"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:eefebcc5c555803065128401a1e224a64607259b5eb907021bf9b175f315d2a6"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-win32.whl", hash = "sha256:3423dc2a3b94125094897118b52bdf4d37daf142cbcf26d48af284b763ab90e9"}, + {file = "SQLAlchemy-2.0.20-cp39-cp39-win_amd64.whl", hash = "sha256:5ed61e3463021763b853628aef8bc5d469fe12d95f82c74ef605049d810f3267"}, + {file = "SQLAlchemy-2.0.20-py3-none-any.whl", hash = "sha256:63a368231c53c93e2b67d0c5556a9836fdcd383f7e3026a39602aad775b14acf"}, + {file = "SQLAlchemy-2.0.20.tar.gz", hash = "sha256:ca8a5ff2aa7f3ade6c498aaafce25b1eaeabe4e42b73e25519183e4566a16fc6"}, +] + +[package.dependencies] +greenlet = {version = "!=0.4.17", markers = "platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\""} +typing-extensions = ">=4.2.0" + +[package.extras] +aiomysql = ["aiomysql (>=0.2.0)", "greenlet (!=0.4.17)"] +aiosqlite = ["aiosqlite", "greenlet (!=0.4.17)", "typing-extensions (!=3.10.0.1)"] +asyncio = ["greenlet (!=0.4.17)"] +asyncmy = ["asyncmy (>=0.2.3,!=0.2.4,!=0.2.6)", "greenlet (!=0.4.17)"] +mariadb-connector = ["mariadb (>=1.0.1,!=1.1.2,!=1.1.5)"] +mssql = ["pyodbc"] +mssql-pymssql = ["pymssql"] +mssql-pyodbc = ["pyodbc"] +mypy = ["mypy (>=0.910)"] +mysql = ["mysqlclient (>=1.4.0)"] +mysql-connector = ["mysql-connector-python"] +oracle = ["cx-oracle (>=7)"] +oracle-oracledb = ["oracledb (>=1.0.1)"] +postgresql = ["psycopg2 (>=2.7)"] +postgresql-asyncpg = ["asyncpg", "greenlet (!=0.4.17)"] +postgresql-pg8000 = ["pg8000 (>=1.29.1)"] +postgresql-psycopg = ["psycopg (>=3.0.7)"] +postgresql-psycopg2binary = ["psycopg2-binary"] +postgresql-psycopg2cffi = ["psycopg2cffi"] +postgresql-psycopgbinary = ["psycopg[binary] (>=3.0.7)"] +pymysql = ["pymysql"] +sqlcipher = ["sqlcipher3-binary"] + +[[package]] +name = "typing-extensions" +version = "4.7.1" +description = "Backported and Experimental Type Hints for Python 3.7+" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, + {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, +] + +[[package]] +name = "werkzeug" +version = "2.3.7" +description = "The comprehensive WSGI web application library." +optional = false +python-versions = ">=3.8" +files = [ + {file = "werkzeug-2.3.7-py3-none-any.whl", hash = "sha256:effc12dba7f3bd72e605ce49807bbe692bd729c3bb122a3b91747a6ae77df528"}, + {file = "werkzeug-2.3.7.tar.gz", hash = "sha256:2b8c0e447b4b9dbcc85dd97b6eeb4dcbaf6c8b6c3be0bd654e25553e0a2157d8"}, +] + +[package.dependencies] +MarkupSafe = ">=2.1.1" + +[package.extras] +watchdog = ["watchdog (>=2.3)"] + +[[package]] +name = "wtforms" +version = "3.0.1" +description = "Form validation and rendering for Python web development." +optional = false +python-versions = ">=3.7" +files = [ + {file = "WTForms-3.0.1-py3-none-any.whl", hash = "sha256:837f2f0e0ca79481b92884962b914eba4e72b7a2daaf1f939c890ed0124b834b"}, + {file = "WTForms-3.0.1.tar.gz", hash = "sha256:6b351bbb12dd58af57ffef05bc78425d08d1914e0fd68ee14143b7ade023c5bc"}, +] + +[package.dependencies] +MarkupSafe = "*" + +[package.extras] +email = ["email-validator"] + +[[package]] +name = "zipp" +version = "3.16.2" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.8" +files = [ + {file = "zipp-3.16.2-py3-none-any.whl", hash = "sha256:679e51dd4403591b2d6838a48de3d283f3d188412a9782faadf845f298736ba0"}, + {file = "zipp-3.16.2.tar.gz", hash = "sha256:ebc15946aa78bd63458992fc81ec3b6f7b1e92d51c35e6de1c3804e73b799147"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.9" +content-hash = "ee0499ca6399970a056817e39a80be7b51eebc9b8cc0759fcc81973630910127" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..6409ed296 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,24 @@ +[tool.poetry] +name = "udacity-fullstack-orm-project" +version = "0.1.0" +description = "" +authors = ["Tzu-Fan Tang"] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.9" +flask = "^2.3.3" +sqlalchemy = "^2.0.20" +flask-sqlalchemy = "^3.0.5" +flask-migrate = "^4.0.4" +babel = "^2.12.1" +flask-moment = "^1.0.5" +flask-wtf = "^1.1.1" +psycopg2-binary = "^2.9.7" +python-dateutil = "^2.8.2" +pytz = "^2023.3" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 16d8ace89..000000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -babel==2.9.0 -python-dateutil==2.6.0 -flask-moment==0.11.0 -flask-wtf==0.14.3 -flask_sqlalchemy==2.4.4 diff --git a/util.py b/util.py new file mode 100644 index 000000000..da0048de7 --- /dev/null +++ b/util.py @@ -0,0 +1,14 @@ +import dateutil.parser +import babel + +#----------------------------------------------------------------------------# +# Utils +#----------------------------------------------------------------------------# + +def format_datetime(value, format='medium'): + date = dateutil.parser.parse(value) + if format == 'full': + format="EEEE MMMM, d, y 'at' h:mma" + elif format == 'medium': + format="EE MM, dd, y h:mma" + return babel.dates.format_datetime(date, format, locale='en') diff --git a/validate.py b/validate.py new file mode 100644 index 000000000..095d45f6b --- /dev/null +++ b/validate.py @@ -0,0 +1,6 @@ +import re + + +def is_valid_phone(number: str): + regex = re.compile(r'^\(?[0-9]{3}\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$') + return regex.match(number)