async def post(self): group = self.model_by_id(GroupModel, "group_id") for membership in group.memberships: if membership.user == self.current_user: session.delete(membership) session.commit() for identity in self.current_user.slack_identities: member = await slack.user_email_to_id(identity.email) await slack.group_kick(group.slug, member) await slack.group_message( group.slug, "Member left: {}".format( self.current_user.main_character.character_name)) break else: raise tornado.web.HTTPError(400) sec_log.info("user {} left group {}".format(membership.user, membership.group)) return self.redirect("/groups/leave/success?group_id={}".format( group.id))
async def post(self): membership = self.model_by_id(MembershipModel, "membership_id") group_id = membership.group.id session.delete(membership) session.commit() self.flash_success( self.locale.translate("MEMBERSHIP_DENY_SUCCESS_ALERT")) self.redirect("/admin/groups/manage?group_id={}".format(group_id))
async def post(self): slackidentity = self.model_by_id(SlackIdentityModel, "slackidentity_id") session.delete(slackidentity) session.commit() self.flash_success( self.locale.translate( "SERVICES_DELETE_SLACK_IDENTITY_SUCCESS_ALERT")) return self.redirect("/services")
async def post(self): membership = self.model_by_id(MembershipModel, "membership_id") group_id = membership.group.id for identity in membership.user.slack_identities: member = await slack.user_email_to_id(identity.email) await slack.group_kick(membership.group.slug, member) session.delete(membership) session.commit() self.flash_success( self.locale.translate("MEMBERSHIP_DENY_SUCCESS_ALERT")) self.redirect("/admin/groups/manage?group_id={}".format(group_id))
def refresh_group_members(group_id, recurring=60): """Refresh a group and kick any members that are not internal.""" group = session.query(GroupModel).filter(GroupModel.id == group_id).one() job_log.debug("group.refresh_group_members {}".format(group)) for membership in group.memberships: if not membership.user.is_internal: job_log.warn( "group.refresh_group_members removing {} from {} no_internal". format(membership.user, group)) session.delete(membership) session.commit() if recurring: refresh_group_members.apply_async(args=(group_id, recurring), countdown=recurring)
async def post(self): group = self.model_by_id(GroupModel, "group_id") for membership in group.memberships: if membership.user == self.current_user: session.delete(membership) session.commit() break else: raise tornado.web.HTTPError(400) sec_log.info("user {} left group {}".format(membership.user, membership.group)) # XXX move to task #await slack.group_upkeep(group) return self.redirect("/groups/leave/success?group_id={}".format( group.id))
def refresh_character_skills(self, character_id, recurring=14400): try: character = session.query(CharacterModel).filter( CharacterModel.id == character_id).one() job_log.debug("user.refresh_character_skills {}".format( character.character_name)) try: skills = esi_characters.skills(character.character_id, access_token=character.access_token) except (InvalidToken, ExpiredToken): try: refresh_access_token(character) skills = esi_characters.skills( character.character_id, access_token=character.access_token) except: return job_log.warn( "removing user.refresh_character_ship {}".format( character.character_name)) if skills and "skills" in skills: # XXX why can skills be None here? skills = skills["skills"] for skill in skills: skill_id = skill["skill_id"] eveskill = EVESkillModel.from_id(skill_id) session.add(eveskill) session.commit() skill_level = skill["current_skill_level"] skill_points = skill["skillpoints_in_skill"] characterskills = session.query(CharacterSkillModel).filter( CharacterSkillModel.character_id == character.id).filter( CharacterSkillModel.eve_skill_id == eveskill.id).all() # XXX why? for characterskill in characterskills: session.delete(characterskill) session.commit() characterskill = CharacterSkillModel(character) characterskill.eve_skill = eveskill characterskill.level = skill_level characterskill.points = skill_points session.add(characterskill) session.commit() if recurring: refresh_character_skills.apply_async(args=(character_id, recurring), countdown=recurring) except requests.exceptions.ConnectionError as e: self.retry(exc=e)