| Line 5... |
Line 5... |
| 5 |
'''
|
5 |
'''
|
| 6 |
from shop2020.model.v1.user.impl import Dataservice
|
6 |
from shop2020.model.v1.user.impl import Dataservice
|
| 7 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
7 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
| 8 |
from shop2020.model.v1.user.impl.Dataservice import User, UserCommunication, IPMap,\
|
8 |
from shop2020.model.v1.user.impl.Dataservice import User, UserCommunication, IPMap,\
|
| 9 |
Address, SocialHandle, UserState, InternalInfo, SocialService, Affiliate, Tracker, TrackLog,\
|
9 |
Address, SocialHandle, UserState, InternalInfo, SocialService, Affiliate, Tracker, TrackLog,\
|
| 10 |
MasterAffiliate
|
10 |
MasterAffiliate, UserNote
|
| 11 |
from shop2020.thriftpy.model.v1.user.ttypes import UserContextException,\
|
11 |
from shop2020.thriftpy.model.v1.user.ttypes import UserContextException,\
|
| 12 |
AuthenticationException, AccountStatus, Sex
|
12 |
AuthenticationException, AccountStatus, Sex
|
| 13 |
from shop2020.clients.HelperClient import HelperClient
|
13 |
from shop2020.clients.HelperClient import HelperClient
|
| 14 |
from elixir import session
|
14 |
from elixir import session
|
| 15 |
import datetime, random, string
|
15 |
import datetime, random, string
|
| Line 493... |
Line 493... |
| 493 |
# raises the UserContextException
|
493 |
# raises the UserContextException
|
| 494 |
#===============================================================================
|
494 |
#===============================================================================
|
| 495 |
def raise_user_exception(user_id):
|
495 |
def raise_user_exception(user_id):
|
| 496 |
raise UserContextException(101, "no such user in system %d" %(user_id))
|
496 |
raise UserContextException(101, "no such user in system %d" %(user_id))
|
| 497 |
|
497 |
|
| - |
|
498 |
'''
|
| - |
|
499 |
My Notes methods
|
| - |
|
500 |
'''
|
| - |
|
501 |
def get_user_notes(user_id, entity_id):
|
| - |
|
502 |
return UserNote.query.filter_by(user_id = user_id).filter_by(entity_id = entity_id).all()
|
| - |
|
503 |
|
| - |
|
504 |
def put_user_note(user_id, entity_id, slide_id, note):
|
| - |
|
505 |
user_notes = UserNote.query.filter_by(user_id = user_id).filter_by(entity_id = entity_id).filter_by(slide_id = slide_id).all()
|
| - |
|
506 |
|
| - |
|
507 |
if user_notes is None or len(user_notes) == 0:
|
| - |
|
508 |
user_note = UserNote()
|
| - |
|
509 |
user_note.user_id = user_id
|
| - |
|
510 |
user_note.entity_id = entity_id
|
| - |
|
511 |
user_note.slide_id = slide_id
|
| - |
|
512 |
user_note.note = note
|
| - |
|
513 |
else:
|
| - |
|
514 |
user_note = user_notes.pop()
|
| - |
|
515 |
user_note.note = note
|
| - |
|
516 |
|
| - |
|
517 |
session.commit()
|
| - |
|
518 |
|
| 498 |
def close_session():
|
519 |
def close_session():
|
| 499 |
if session.is_active:
|
520 |
if session.is_active:
|
| 500 |
print "session is active. closing it."
|
521 |
print "session is active. closing it."
|
| 501 |
session.close()
|
522 |
session.close()
|
| 502 |
|
523 |
|