Skip to content

Commit 6a3a410

Browse files
committed
feat: added add your favourite movie
1 parent 4ef4639 commit 6a3a410

File tree

5 files changed

+79
-7
lines changed

5 files changed

+79
-7
lines changed

Diff for: TopMovieList/app.py

+21
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class RateMovieForm(FlaskForm):
4242
submit = SubmitField("Done")
4343

4444

45+
# find movies from The Movie Database
46+
class FindMovieForm(FlaskForm):
47+
title = StringField('Movie Title', validators=[DataRequired()])
48+
submit = SubmitField("Add Movie")
49+
50+
4551
@app.route('/')
4652
def home():
4753
# get all the movies from DB
@@ -66,5 +72,20 @@ def rate_movie():
6672
return render_template('edit.html', movie=movie, form=form)
6773

6874

75+
@app.route('/delete')
76+
def delete_movie():
77+
movie_id = request.args.get("id")
78+
movie = Movie.query.get(movie_id)
79+
db.session.delete(movie)
80+
db.session.commit()
81+
return redirect(url_for('home'))
82+
83+
84+
@app.route('/add', methods=["GET", "POST"])
85+
def add_movie():
86+
form = FindMovieForm()
87+
return render_template("add.html", form=form)
88+
89+
6990
if __name__ == '__main__':
7091
app.run()

Diff for: TopMovieList/movies.db

0 Bytes
Binary file not shown.

Diff for: TopMovieList/templates/add.html

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{% extends 'bootstrap/base.html' %}
2+
{% import 'bootstrap/wtf.html' as wtf %}
3+
4+
{% block styles %}
5+
{{ super() }}
6+
7+
<!-- Google Fonts -->
8+
9+
<link
10+
rel="stylesheet"
11+
href="https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,700"
12+
/>
13+
<link
14+
rel="stylesheet"
15+
href="https://fonts.googleapis.com/css?family=Poppins:300,400,700"
16+
/>
17+
<link
18+
rel="stylesheet"
19+
href="https://fonts.googleapis.com/css?family=Poppins:300,400,700"
20+
/>
21+
22+
<!-- Font Awesome CSS -->
23+
<link
24+
rel="stylesheet"
25+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
26+
integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
27+
crossorigin="anonymous"
28+
/>
29+
30+
<!-- Custom CSS Styling -->
31+
<link
32+
rel="stylesheet"
33+
href="{{ url_for('static', filename='css/styles.css') }}"
34+
/>
35+
{% endblock %}
36+
37+
{% block title %} Add Movies {% endblock %}
38+
39+
{% block content %}
40+
<div class="container">
41+
42+
<div class="content">
43+
<h1 class="heading">Add A Movie</h1>
44+
45+
{{ wtf.quick_form(form, novalidate=True) }}
46+
</div>
47+
48+
</div>
49+
{% endblock %}

Diff for: TopMovieList/templates/edit.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@
3737
{% block title %} Edit Rating & Reviews {% endblock %}
3838

3939
{% block content %}
40+
<div class="container">
4041

41-
<div class="content">
42-
<h1 class="heading">{{ movie.title }}</h1>
43-
<p class="description">Edit Movie Rating & Reviews</p>
42+
<div class="content">
43+
<h1 class="heading">{{ movie.title }}</h1>
44+
<p class="description">Edit Movie Rating & Reviews</p>
4445

45-
{{ wtf.quick_form(form, novalidate=True) }}
46-
</div>
46+
{{ wtf.quick_form(form, novalidate=True) }}
47+
</div>
4748

49+
</div>
4850
{% endblock %}

Diff for: TopMovieList/templates/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ <h1 class="heading">My Top 10 Movies</h1>
6161
<p class="overview">{{ movie.description }}</p>
6262

6363
<a href="{{ url_for('rate_movie', id=movie.id) }}" class="button">Update</a>
64-
<a href="#" class="button delete-button">Delete</a>
64+
<a href="{{ url_for('delete_movie', id=movie.id) }}" class="button delete-button">Delete</a>
6565

6666
</div>
6767
</div>
6868
</div>
6969
{% endfor %}
7070
</div>
7171
<div class="container text-center add">
72-
<a href="#" class="button">Add Movie</a>
72+
<a href="{{ url_for('add_movie') }}" class="button">Add Movie</a>
7373
</div>
7474

7575
{% endblock %}

0 commit comments

Comments
 (0)