base functionality for storing selected institution of user/person in favorites
This commit is contained in:
parent
a3e0cac006
commit
335217081c
2 changed files with 18 additions and 3 deletions
|
@ -149,8 +149,8 @@ class SortableMixin(object):
|
|||
dir = 'asc'
|
||||
result[tableName] = dict(
|
||||
colName=fn, ascending=(dir=='asc'), fparam=v)
|
||||
result = favorite.update(getPersonForUser(
|
||||
self.context, self.request), self.target, 'sort', result)
|
||||
result = favorite.updateSortInfo(getPersonForUser(
|
||||
self.context, self.request), self.target, result)
|
||||
return result
|
||||
|
||||
def isSortableColumn(self, tableName, colName):
|
||||
|
|
|
@ -89,7 +89,7 @@ class Favorite(Track):
|
|||
return self.data.get('type') or 'favorite'
|
||||
|
||||
|
||||
def update(person, task, type, data):
|
||||
def updateSortInfo(person, task, data):
|
||||
if person is not None:
|
||||
favorites = task.getLoopsRoot().getRecordManager().get('favorites')
|
||||
if favorites is None:
|
||||
|
@ -112,3 +112,18 @@ def update(person, task, type, data):
|
|||
Favorites(favorites).add(task, person,
|
||||
dict(type='sort', sortInfo=data))
|
||||
return data
|
||||
|
||||
|
||||
def setInstitution(person, inst):
|
||||
if person is not None:
|
||||
favorites = inst.getLoopsRoot().getRecordManager().get('favorites')
|
||||
if favorites is None:
|
||||
return
|
||||
personUid = util.getUidForObject(person)
|
||||
taskUid = util.getUidForObject(inst)
|
||||
for fav in favorites.query(userName=personUid):
|
||||
if fav.type == 'institution':
|
||||
fav.taskId = taskUid
|
||||
favorites.indexTrack(None, fav, 'taskId')
|
||||
else:
|
||||
Favorites(favorites).add(inst, person, dict(type='institution'))
|
||||
|
|
Loading…
Add table
Reference in a new issue