conn = sqlite3.connect(DATABASE)
c = conn.cursor()
-for vote in c.execute('select id, id_group, date_end, title from votes where is_open=1 and is_terminated=0'):
+for vote in c.execute('select id, id_group, date_end, title from votes where is_open=1 and is_terminated=0').fetchall():
date_end_vote = datetime.strptime(vote[2], "%Y-%m-%d")
date_today = datetime.today()
date_begin_reminder = date_end_vote + timedelta(days=-3)
- if date_today >= date_begin_reminder and date_today <= date_end_vote:
+ date_cursor = date_today
+ is_anniversary = False
+ while not is_anniversary and date_cursor <= date_end_vote:
+ date_cursor = date_cursor + timedelta(days=7)
+ print date_cursor
+ if date_cursor >= date_end_vote and date_cursor <= date_end_vote + timedelta(days=1):
+ print "Is anniversary"
+ is_anniversary = True
+
+ if date_today >= date_begin_reminder and date_today <= date_end_vote or is_anniversary:
voting_group = (vote[1],)
for user in c.execute('select users.id, users.email, users.name from users join user_group on users.id=user_group.id_user where user_group.id_group = ?', voting_group).fetchall():
userchoice_request = (user[0], vote[0],)