本文整理汇总了Python中nagare.database.session.flush函数的典型用法代码示例。如果您正苦于以下问题:Python flush函数的具体用法?Python flush怎么用?Python flush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flush函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: insert_card
def insert_card(self, index, card):
done = False
if card not in self.cards:
self.cards.insert(index, card)
session.flush()
done = True
return done
开发者ID:Net-ng,项目名称:kansha,代码行数:7,代码来源:models.py
示例2: populate_states
def populate_states():
workflow = get_workflow()
WFSteps = workflow.WFSteps
WFStates = workflow.WFStates
states = (
(WFStates.INITIAL_STATE, WFSteps.NO_STEP),
(WFStates.DRAFT_STATE, WFSteps.NO_STEP),
(WFStates.FI_NORMALIZE_STATE, WFSteps.SUBMITTED_STEP),
(WFStates.AUTHOR_NORMALIZE_STATE, WFSteps.SUBMITTED_STEP),
(WFStates.DI_APPRAISAL_STATE, WFSteps.STUDY_STEP),
(WFStates.RETURNED_BY_DI_STATE, WFSteps.STUDY_STEP),
(WFStates.DI_APPROVED_STATE, WFSteps.SUGGESTED_STEP),
(WFStates.SELECTED_STATE, WFSteps.SELECTED_STEP),
(WFStates.PROJECT_STATE, WFSteps.PROJECT_STEP),
(WFStates.PROTOTYPE_STATE, WFSteps.PROTOTYPE_STEP),
(WFStates.EXTENDED_STATE, WFSteps.EXTENDED_STEP),
(WFStates.FI_REFUSED_STATE, WFSteps.SUBMITTED_STEP),
(WFStates.PROTOTYPE_REFUSED_STATE, WFSteps.PROTOTYPE_STEP),
(WFStates.DI_REFUSED_STATE, WFSteps.STUDY_STEP),
(WFStates.PROJECT_REFUSED_STATE, WFSteps.PROJECT_STEP),
(WFStates.SELECT_REFUSED_STATE, WFSteps.SELECTED_STEP),
(WFStates.APPROVAL_REFUSED_STATE, WFSteps.SUGGESTED_STEP),
(WFStates.DSIG_BASKET_STATE, WFSteps.NO_STEP),
)
for label, step in states:
step = StepData.get_by(label=step)
StateData(label=label, step=step)
session.flush()
开发者ID:droodle,项目名称:eureka-opensource,代码行数:31,代码来源:populate.py
示例3: move_cards
def move_cards(self, v):
"""Function called after drag and drop of a card or column
In:
- ``v`` -- a structure containing the lists/cards position
(ex . [ ["list_1", ["card_1", "card_2"]],
["list_2", ["card_3", "card_4"]] ])
"""
security.check_permissions('edit', self)
ids = json.loads(v)
cards = {}
cols = {}
for col in self.columns:
cards.update(dict([(card().id, card) for card in col().cards
if not isinstance(card(), popin.Empty)]))
cols[col().id] = col
# move columns
self.columns = []
for (col_index, (col_id, card_ids)) in enumerate(ids):
comp_col = cols[col_id]
self.columns.append(comp_col)
comp_col().change_index(col_index)
comp_col().move_cards([cards[id_] for id_ in card_ids])
session.flush()
开发者ID:gpaugam,项目名称:kansha,代码行数:27,代码来源:comp.py
示例4: test_get_by_role
def test_get_by_role(self):
user = create_user()
create_user()
user.add_role(RoleType.Facilitator)
session.flush()
facilitators = self.user_repository.get_facilitators()
self.assertTrue(user in facilitators)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:7,代码来源:test_user.py
示例5: add
def add(self, v):
"""Add a new comment to the card
In:
- ``v`` -- the comment content
"""
security.check_permissions("comment", self.parent)
if v is None:
return
v = v.strip()
if v:
v = validator.clean_text(v)
user = security.get_user()
comment = DataComment(
comment=v.strip(),
card_id=self.parent.data.id,
author=user.data,
creation_date=datetime.datetime.utcnow(),
)
session.add(comment)
session.flush()
data = {"comment": v.strip(), "card": self.parent.title().text}
notifications.add_history(
self.parent.column.board.data, self.parent.data, security.get_user().data, u"card_add_comment", data
)
self.comments.insert(0, self._create_comment_component(comment))
开发者ID:Reigel,项目名称:kansha,代码行数:26,代码来源:comp.py
示例6: update_card_position
def update_card_position(self, data):
security.check_permissions('edit', self)
data = json.loads(data)
cols = {}
for col in self.columns:
cols[col().id] = col()
orig = cols[data['orig']]
if data['orig'] != data['dest']: # Move from one column to another
dest = cols[data['dest']]
card = orig.remove_card(data['card'])
dest.insert_card(card, data['index'])
values = {'from': orig.title().text,
'to': dest.title().text,
'card': card().data.title}
notifications.add_history(self.data, card().data,
security.get_user().data,
u'card_move', values)
# reindex it in case it has been moved to the archive column
scard = fts_schema.Card.from_model(card().data)
self.search_engine.update_document(scard)
self.search_engine.commit()
else: # Reorder only
orig.move_card(data['card'], data['index'])
session.flush()
开发者ID:gpaugam,项目名称:kansha,代码行数:27,代码来源:comp.py
示例7: create_template_empty
def create_template_empty():
board = DataBoard(title=u'Empty board', is_template=True, visibility=1)
board.weight_config = DataBoardWeightConfig()
for title, color in DEFAULT_LABELS:
board.create_label(title=title, color=color)
session.flush()
return board
开发者ID:Net-ng,项目名称:kansha,代码行数:7,代码来源:models.py
示例8: copy
def copy(self, parent):
new_data = DataColumn(title=self.title,
index=self.index,
nb_max_cards=self.nb_max_cards,
board=parent)
session.flush()
return new_data
开发者ID:daamien,项目名称:kansha,代码行数:7,代码来源:models.py
示例9: update_user
def update_user(self):
# checks the other fields and updates data
if super(UserLineEditor, self).commit((), ('corporation_id', 'direction_id', 'site_id', 'service_id', 'fi_uid', 'enabled')):
# FIXME: use the OrganizationRepository
get_orga = lambda id: OrganizationData.get(
id) if id != -1 else None
u = self.user_repository.get_by_uid(self.uid)
u.corporation = get_orga(self.corporation_id())
u.direction = get_orga(self.direction_id())
u.service = get_orga(self.service_id())
u.site = get_orga(self.site_id())
u.subsite = get_orga(self.subsite_id())
u.enabled = self.enabled()
u.fi_uid = self.fi_uid()
session.flush()
self.orig_corp_id = u.corporation_id or -1L
self.orig_dir_id = u.direction_id or -1L
self.orig_service_id = u.service_id or -1L
self.orig_site_id = u.site_id or -1L
self.orig_subsite_id = u.subsite_id or -1L
self.orig_enabled = u.enabled
self.orig_fi_uid = u.fi_uid
flashmessage.set_flash(_(u'User modified'))
return True
开发者ID:droodle,项目名称:eureka-opensource,代码行数:30,代码来源:comp.py
示例10: copy
def copy(self, parent):
new_data = DataLabel(title=self.title,
color=self.color,
index=self.index,
board=parent)
session.flush()
return new_data
开发者ID:daamien,项目名称:kansha,代码行数:7,代码来源:models.py
示例11: create_template_todo
def create_template_todo():
board = DataBoard(title=u'Todo', is_template=True, visibility=1)
for index, title in enumerate((u'To Do', u'Doing', u'Done')):
board.create_column(index, title)
for title, color in DEFAULT_LABELS:
board.create_label(title=title, color=color)
session.flush()
return board
开发者ID:daamien,项目名称:kansha,代码行数:8,代码来源:models.py
示例12: test_photo
def test_photo(self):
user = create_user()
photo = self.create_photo(50)
user.photo = photo
session.flush()
self.assertTrue(user.photo is not None)
user.photo = None
self.assertTrue(user.photo is None)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:8,代码来源:test_user.py
示例13: append_card
def append_card(self, card):
done = False
if card not in self.cards:
card.index = None
self.cards.append(card)
session.flush()
done = True
return done
开发者ID:Net-ng,项目名称:kansha,代码行数:8,代码来源:models.py
示例14: test_remove_existing_role
def test_remove_existing_role(self):
user = create_user()
user.add_role(RoleType.Facilitator)
session.flush()
user.remove_role(RoleType.Facilitator)
self.assert_(not user.has_role(RoleType.Facilitator))
session.flush()
facilitators = self.user_repository.get_facilitators()
self.assert_(user not in facilitators)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:9,代码来源:test_user.py
示例15: import_article_topics_csv
def import_article_topics_csv(csv_file):
reader = UnicodeDictReader(csv_file, delimiter=';')
for row in reader:
article = ArticleTopicData()
article.label = row['label'].strip()
article.key = row['key'].strip()
article.default = int(row['default'].strip())
session.flush()
开发者ID:droodle,项目名称:eureka-opensource,代码行数:10,代码来源:populate.py
示例16: test_enabled
def test_enabled(self):
uid = u'jdoe'
create_user(uid=uid)
session.flush()
user = self.user_repository.get_by_uid(uid)
self.assert_(user.enabled) # this is what we want most of the time
user.enabled = False
session.flush()
user = self.user_repository.get_by_uid(uid)
self.assert_(not user.enabled)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:10,代码来源:test_user.py
示例17: create_board
def create_board():
"""Create boards with default columns and default cards
"""
user_test = get_or_create_data_user()
data_board = boardsmanager.BoardsManager().create_board(word(), user_test,
True)
session.add(data_board)
session.flush()
_services = create_services()
return _services(board.Board, data_board.id, 'boards', '', '', None)
开发者ID:Reigel,项目名称:kansha,代码行数:10,代码来源:helpers.py
示例18: create_board
def create_board():
"""Create boards with default columns and default cards
"""
user_test = get_or_create_data_user()
data_board = boardsmanager.BoardsManager().create_board(word(), user_test,
True)
session.add(data_board)
session.flush()
assets_manager = DummyAssetsManager()
return board.Board(data_board.id, 'boards', '', '', '', assets_manager, None)
开发者ID:droodle,项目名称:kansha,代码行数:10,代码来源:helpers.py
示例19: delete_comment
def delete_comment(self, comp):
"""Delete a comment.
In:
- ``comment`` -- the comment to delete
"""
self.comments.remove(comp)
comment = comp()
DataComment.get(comment.db_id).delete()
session.flush()
开发者ID:daamien,项目名称:kansha,代码行数:10,代码来源:comp.py
示例20: import_domains_csv
def import_domains_csv(csv_file):
reader = UnicodeDictReader(csv_file, delimiter=';')
for line in reader:
d = DomainData()
d.label = line['label'].strip()
d.rank = int(line['rank'].strip())
d.en_label = line['en_label'].strip()
d.fr_label = line['fr_label'].strip()
session.flush()
开发者ID:droodle,项目名称:eureka-opensource,代码行数:11,代码来源:populate.py
注:本文中的nagare.database.session.flush函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论