File tree 5 files changed +79
-7
lines changed
5 files changed +79
-7
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ class RateMovieForm(FlaskForm):
42
42
submit = SubmitField ("Done" )
43
43
44
44
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
+
45
51
@app .route ('/' )
46
52
def home ():
47
53
# get all the movies from DB
@@ -66,5 +72,20 @@ def rate_movie():
66
72
return render_template ('edit.html' , movie = movie , form = form )
67
73
68
74
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
+
69
90
if __name__ == '__main__' :
70
91
app .run ()
Original file line number Diff line number Diff line change
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 %}
Original file line number Diff line number Diff line change 37
37
{% block title %} Edit Rating & Reviews {% endblock %}
38
38
39
39
{% block content %}
40
+ < div class ="container ">
40
41
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 >
44
45
45
- {{ wtf.quick_form(form, novalidate=True) }}
46
- </ div >
46
+ {{ wtf.quick_form(form, novalidate=True) }}
47
+ </ div >
47
48
49
+ </ div >
48
50
{% endblock %}
Original file line number Diff line number Diff line change @@ -61,15 +61,15 @@ <h1 class="heading">My Top 10 Movies</h1>
61
61
< p class ="overview "> {{ movie.description }}</ p >
62
62
63
63
< 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 >
65
65
66
66
</ div >
67
67
</ div >
68
68
</ div >
69
69
{% endfor %}
70
70
</ div >
71
71
< 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 >
73
73
</ div >
74
74
75
75
{% endblock %}
You can’t perform that action at this time.
0 commit comments