Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix sending of sit accepted emails. Need to keep track of when the si…

…t was accepted.
  • Loading branch information...
commit 0acfb6da859ef7f53ee6aaf3a2b85ab93477bfb6 1 parent 0c105fe
@dsully authored
Showing with 10 additions and 4 deletions.
  1. +4 −1 bin/manage
  2. +6 −3 sitter/models.py
View
5 bin/manage
@@ -129,7 +129,10 @@ def daily():
for request in SitRequest.taken_requests():
- if ((datetime.now() - request.ctime) < timedelta(days=1)):
+ if request.atime is None:
+ continue
+
+ if ((datetime.now() - request.atime) < timedelta(days=1)):
request.send_accept_email()
##########################
View
9 sitter/models.py
@@ -354,7 +354,9 @@ class SitRequest(db.Model):
id = db.Column(db.Integer, primary_key=True)
cancelled = db.Column(db.Boolean, default=False)
+ # creation time, accepted time
ctime = db.Column(db.DateTime, default=datetime.now)
+ atime = db.Column(db.DateTime, nullable=True)
start_time = db.Column(db.DateTime)
end_time = db.Column(db.DateTime)
reported = db.Column(db.Float, nullable=True)
@@ -489,6 +491,7 @@ def accept(cls, id, acceptee):
else:
sit.sitter = acceptee.family
+ sit.atime = datetime.now()
db.session.merge(sit)
db.session.commit()
@@ -550,13 +553,13 @@ def decline(cls, id):
""" The sitting family can decline a :class:`SitRequest` & send email. """
sit = SitRequest.query.get(id)
- sitter = sit.sitter
+ sit.send_decline_email(sit.sitter)
+
sit.sitter = None
+ sit.atime = None
db.session.merge(sit)
db.session.commit()
- sit.send_decline_email(sitter)
-
return sit
def send_decline_email(self, sitter):
Please sign in to comment.
Something went wrong with that request. Please try again.