Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MyMovieLibrary
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
MyMovieLibrary
Commits
bfc5f671
Commit
bfc5f671
authored
11 years ago
by
Brian Wood
Browse files
Options
Downloads
Patches
Plain Diff
Wrote email reminder service and added config settings in __init__.py
parent
b6dcb8fd
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
project/__init__.py
+6
-2
6 additions, 2 deletions
project/__init__.py
project/controllers/loan.py
+31
-1
31 additions, 1 deletion
project/controllers/loan.py
project/model/Movie.py
+6
-1
6 additions, 1 deletion
project/model/Movie.py
with
43 additions
and
4 deletions
project/__init__.py
+
6
−
2
View file @
bfc5f671
...
...
@@ -10,11 +10,15 @@ sys.path.append('../pytmdb3/')
from
tmdb3
import
set_key
set_key
(
'
542606a6ccff81a0337dc370a0cbfc37
'
)
app
=
Flask
(
'
project
'
)
app
.
config
[
'
SECRET_KEY
'
]
=
'
random
'
app
.
config
[
'
MONGODB_SETTINGS
'
]
=
{
'
DB
'
:
'
my_movie_library
'
}
app
.
config
[
'
SMTP_USER
'
]
=
""
app
.
config
[
'
SMTP_PASSWORD
'
]
=
""
app
.
config
[
'
SMTP_SERVER
'
]
=
"
smtp.gmail.com:587
"
app
.
config
[
'
TMDB_API_KEY
'
]
=
""
set_key
(
app
.
config
[
'
TMDB_API_KEY
'
])
# app.config["MONGODB_SETTINGS"] = {'DB': "my_movie_library",
# 'host': '192.168.1.89'}
app
.
debug
=
True
...
...
This diff is collapsed.
Click to expand it.
project/controllers/loan.py
+
31
−
1
View file @
bfc5f671
...
...
@@ -7,3 +7,33 @@ from flask.ext.wtf import Form, TextField, validators
@security
(
'
user
'
)
def
loaned
(
user
=
None
):
return
render_template
(
'
loan/master.html
'
,
user
=
user
)
@app.route
(
'
/send-reminder
'
,
methods
=
[
'
POST
'
])
@security
(
'
user
'
)
def
reminderEmail
(
user
=
None
):
from_addr
=
user
.
email
to_addr
=
request
.
form
[
'
email
'
]
subject
=
request
.
form
[
'
subject
'
]
or
"
Movie Return Reminder
"
movie_id
=
request
.
form
[
'
movie
'
]
if
not
movie_id
:
return
jsonify
(
response
=
'
error
'
,
message
=
'
Invalid Movie given
'
),
404
from
project.model.Movie
import
Movie
movie
=
Movie
.
objects
(
id
=
movie_id
).
first
()
if
not
movie
:
return
jsonify
(
response
=
'
error
'
,
message
=
'
Invalid Movie given
'
),
404
loan
=
movie
.
getLoan
(
user
)
message
=
request
.
form
[
'
message
'
]
or
"
The movie %s, borrowed form %s is due on %s
"
%
(
movie
.
title
,
user
.
email
,
loan
.
expected_return_date
)
login
=
app
.
config
[
'
SMTP_USER
'
]
password
=
app
.
config
[
'
SMTP_PASSWORD
'
]
smtpserver
=
app
.
config
[
'
SMTP_SERVER
'
]
header
=
'
From: %s
\n
'
%
from_addr
header
+=
'
To: %s
\n
'
%
to_addr
header
+=
'
Subject: %s
\n\n
'
%
subject
message
=
header
+
message
server
=
smtplib
.
SMTP
(
smtpserver
)
server
.
starttls
()
server
.
login
(
login
,
password
)
problems
=
server
.
sendmail
(
from_addr
,
to_addr
,
message
)
server
.
quit
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
project/model/Movie.py
+
6
−
1
View file @
bfc5f671
...
...
@@ -21,6 +21,11 @@ class Movie(db.Document):
self
.
tags
.
remove
(
tag
)
return
self
def
getLoan
(
self
,
user
):
from
Loan
import
Loan
loan
=
Loan
.
objects
(
movie
=
self
,
user
=
user
).
first
()
return
loan
def
__str__
(
self
):
return
self
.
title
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment