def apply_union(self, union_id): # 申请加入工会 from core.union.union import Union, UnionList doc = MongoUnion._get_collection().find_one({'_id': union_id}, {'owner': 1}) if not doc: raise SanguoException(errormsg.UNION_NOT_EXIST, self.char_id, "Member Apply Union", "union {0} not exist".format(union_id)) if self.mongo_union_member.joined: raise SanguoException( errormsg.UNION_CANNOT_APPLY_ALREADY_IN, self.char_id, "Member Apply Union", "already in {0}".format(self.mongo_union_member.joined)) if len(self.mongo_union_member.applied) >= 10: raise SanguoException(errormsg.UNION_CANNOT_APPLY_FULL, self.char_id, "Member Apply Union", "apply list too long") if union_id not in self.mongo_union_member.applied: self.mongo_union_member.applied.append(union_id) self.mongo_union_member.save() Union(doc['owner']).send_apply_list_notify() UnionList.send_list_notify(self.char_id)
def apply_union(self, union_id): # 申请加入工会 from core.union.union import Union, UnionList doc = MongoUnion._get_collection().find_one( {'_id': union_id}, {'owner': 1} ) if not doc: raise SanguoException( errormsg.UNION_NOT_EXIST, self.char_id, "Member Apply Union", "union {0} not exist".format(union_id) ) if self.mongo_union_member.joined: raise SanguoException( errormsg.UNION_CANNOT_APPLY_ALREADY_IN, self.char_id, "Member Apply Union", "already in {0}".format(self.mongo_union_member.joined) ) if len(self.mongo_union_member.applied) >= 10: raise SanguoException( errormsg.UNION_CANNOT_APPLY_FULL, self.char_id, "Member Apply Union", "apply list too long" ) if union_id not in self.mongo_union_member.applied: self.mongo_union_member.applied.append(union_id) self.mongo_union_member.save() Union(doc['owner']).send_apply_list_notify() UnionList.send_list_notify(self.char_id)
def apply_union(self, union_id): # 申请加入工会 from core.union.union import Union, UnionList try: mongo_union = MongoUnion.objects.get(id=union_id) except DoesNotExist: raise SanguoException( errormsg.UNION_NOT_EXIST, self.char_id, "Member Apply Union", "union {0} not exist".format(union_id) ) if self.mongo_union_member.joined: raise SanguoException( errormsg.UNION_CANNOT_APPLY_ALREADY_IN, self.char_id, "Member Apply Union", "already in {0}".format(self.mongo_union_member.joined) ) if len(self.mongo_union_member.applied) >= 10: raise SanguoException( errormsg.UNION_CANNOT_APPLY_FULL, self.char_id, "Member Apply Union", "apply list too long" ) if union_id not in self.mongo_union_member.applied: self.mongo_union_member.applied.append(union_id) self.mongo_union_member.save() Union(mongo_union.owner).send_apply_list_notify() UnionList.send_list_notify(self.char_id)
def send_notify(char_id): from core.union.battle import UnionBattle from core.union.boss import UnionBoss from core.union.store import UnionStore from core.union.union import Union, UnionList, UnionOwner from core.union.member import Member # 工会列表 UnionList.send_list_notify(char_id) # 个人信息 Member(char_id).send_personal_notify() u = Union(char_id) # UnionNotify u.send_notify() if isinstance(u, UnionOwner): # 会长才能看见的申请者列表 u.send_apply_list_notify() # 商店 UnionStore(char_id).send_notify() # 工会战 UnionBattle(char_id).send_notify()
def get_list(request): char_id = request._char_id UnionList.send_list_notify(char_id) return None