Subversion Repositories SmartDukaan

Rev

Rev 2445 | Rev 3086 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2445 Rev 3005
Line 9... Line 9...
9
from email import encoders
9
from email import encoders
10
import os
10
import os
11
import smtplib
11
import smtplib
12
from shop2020.utils.Utils import log_entry, to_py_date
12
from shop2020.utils.Utils import log_entry, to_py_date
13
from shop2020.helpers.impl.DataService import Message, UserEmail,\
13
from shop2020.helpers.impl.DataService import Message, UserEmail,\
14
    Report, ReportRoleAuthority, CatalogDashboardUser
14
    Report, ReportRoleAuthority, CatalogDashboardUser, UserEmailArchive
15
 
15
 
16
from elixir import *
16
from elixir import *
17
 
17
 
18
from shop2020.thriftpy.utils.ttypes import Message as Msg
18
from shop2020.thriftpy.utils.ttypes import Message as Msg
19
from string import Template
19
from string import Template
Line 39... Line 39...
39
    user_email.timestamp = datetime.datetime.now()
39
    user_email.timestamp = datetime.datetime.now()
40
    session.commit()
40
    session.commit()
41
 
41
 
42
def get_emails_to_be_sent(email_type):
42
def get_emails_to_be_sent(email_type):
43
    print "get_emails_to_be_sent"
43
    print "get_emails_to_be_sent"
44
    return UserEmail.query.filter_by(status = False).all()
44
    return UserEmail.query.all()
45
 
45
 
46
def mark_email_as_sent(email_id):
46
def mark_email_as_sent(email_id):
-
 
47
    query = 'INSERT INTO ' + str(UserEmailArchive.table) + ' (select * from ' + str(UserEmail.table) + ' where id = ' + str(email_id) + ')'
-
 
48
    session.execute(query, mapper=UserEmailArchive)
47
    email = UserEmail.get_by(id = email_id)
49
    email = UserEmail.get_by(id = email_id)
-
 
50
    if email:
48
    email.status = True
51
        email.delete()
49
    session.commit()
52
    session.commit()
50
 
53
 
51
def sendMail(mail):
54
def sendMail(mail):
52
    if not mail:
55
    if not mail:
53
        raise HelperServiceException(101, "mail not present")
56
        raise HelperServiceException(101, "mail not present")