| Line 6... |
Line 6... |
| 6 |
from elixir import *
|
6 |
from elixir import *
|
| 7 |
from email import encoders
|
7 |
from email import encoders
|
| 8 |
from email.mime.base import MIMEBase
|
8 |
from email.mime.base import MIMEBase
|
| 9 |
from email.mime.multipart import MIMEMultipart
|
9 |
from email.mime.multipart import MIMEMultipart
|
| 10 |
from email.mime.text import MIMEText
|
10 |
from email.mime.text import MIMEText
|
| - |
|
11 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 11 |
from shop2020.helpers.impl import DataService
|
12 |
from shop2020.helpers.impl import DataService
|
| 12 |
from shop2020.helpers.impl.DataService import Message, UserEmail, EntitiesShared, \
|
13 |
from shop2020.helpers.impl.DataService import Message, UserEmail, EntitiesShared, \
|
| 13 |
Report, ReportRoleAuthority, CatalogDashboardUser, UserEmailArchive, QuickLink, \
|
14 |
Report, ReportRoleAuthority, CatalogDashboardUser, UserEmailArchive, QuickLink, \
|
| 14 |
AgentWarehouseMapping, UserSms, UserSmsInfo, UserSmsArchive
|
15 |
AgentWarehouseMapping, UserSms, UserSmsInfo, UserSmsArchive, DealerAuth
|
| 15 |
from shop2020.helpers.impl.model.Agent import Agent
|
16 |
from shop2020.helpers.impl.model.Agent import Agent
|
| 16 |
from shop2020.helpers.impl.model.DashboardUser import DashboardUser
|
17 |
from shop2020.helpers.impl.model.DashboardUser import DashboardUser
|
| 17 |
from shop2020.thriftpy.utils.ttypes import HelperServiceException, Mail, \
|
18 |
from shop2020.thriftpy.utils.ttypes import HelperServiceException, Mail, \
|
| 18 |
Message as Msg, SmsStatus, SmsType, SmsDeliveryStatus
|
19 |
Message as Msg, SmsStatus, SmsType, SmsDeliveryStatus
|
| 19 |
from shop2020.utils.Utils import log_entry, to_py_date
|
20 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
| 20 |
from sqlalchemy.orm import query
|
21 |
from sqlalchemy.orm import query
|
| 21 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
22 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
| 22 |
from sqlalchemy.sql import func
|
23 |
from sqlalchemy.sql import func
|
| 23 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct, cast, \
|
24 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct, cast, \
|
| 24 |
between
|
25 |
between
|
| 25 |
from string import Template
|
26 |
from string import Template
|
| 26 |
import datetime
|
27 |
import datetime
|
| 27 |
import os
|
28 |
import os
|
| 28 |
import smtplib
|
29 |
import smtplib
|
| 29 |
from shop2020.clients.CatalogClient import CatalogClient
|
- |
|
| 30 |
|
30 |
|
| 31 |
def initialize(dbname='helper', db_hostname="localhost"):
|
31 |
def initialize(dbname='helper', db_hostname="localhost"):
|
| 32 |
log_entry("initialize@DataAccessor", "Initializing data service")
|
32 |
log_entry("initialize@DataAccessor", "Initializing data service")
|
| 33 |
DataService.initialize(dbname, db_hostname)
|
33 |
DataService.initialize(dbname, db_hostname)
|
| 34 |
|
34 |
|
| Line 411... |
Line 411... |
| 411 |
session.commit()
|
411 |
session.commit()
|
| 412 |
if sms:
|
412 |
if sms:
|
| 413 |
sms.delete()
|
413 |
sms.delete()
|
| 414 |
session.commit()
|
414 |
session.commit()
|
| 415 |
return True
|
415 |
return True
|
| - |
|
416 |
|
| - |
|
417 |
def authorise_dealer(tDealerAuth):
|
| - |
|
418 |
tDealerAuth.isActive = False
|
| - |
|
419 |
if tDealerAuth.username:
|
| - |
|
420 |
dealerAuth = DealerAuth.get_by(username=tDealerAuth.username)
|
| - |
|
421 |
if dealerAuth:
|
| - |
|
422 |
if tDealerAuth.password == dealerAuth.password and dealerAuth.isActive == True:
|
| - |
|
423 |
tDealerAuth.role = dealerAuth.role
|
| - |
|
424 |
if tDealerAuth.lastLocation and dealerAuth.lattitude and dealerAuth.longitude:
|
| - |
|
425 |
dealerAuth.lattitude, dealerAuth.longitude, tDealerAuth.lastLocation.lattitude,tDealerAuth.lastLocation.longitude = tDealerAuth.lastLocation.lattitude,tDealerAuth.lastLocation.longitude, dealerAuth.lattitude, dealerAuth.longitude
|
| - |
|
426 |
if dealerAuth.lastLoggedIn is not None:
|
| - |
|
427 |
tDealerAuth.lastLoggedIn = to_java_date(dealerAuth.lastLoggedIn)
|
| - |
|
428 |
else:
|
| - |
|
429 |
tDealerAuth.lastLoggedIn = None
|
| - |
|
430 |
dealerAuth.lastLoggedIn = datetime.datetime.now()
|
| - |
|
431 |
tDealerAuth.isActive = True
|
| - |
|
432 |
session.commit()
|
| - |
|
433 |
|
| - |
|
434 |
tDealerAuth.password = None
|
| - |
|
435 |
return tDealerAuth
|
| 416 |
|
436 |
|
| 417 |
|
437 |
|
| 418 |
def close_session():
|
438 |
def close_session():
|
| 419 |
if session.is_active:
|
439 |
if session.is_active:
|
| 420 |
print "session is active. closing it."
|
440 |
print "session is active. closing it."
|