def add_entity(self): if not super(FIEditor, self).commit( (), ('corporation_id', 'direction_id', 'service_id', 'site_id')): return False corporation = self._get_organization_label(long(self.corporation_id())) direction = self._get_organization_label(long(self.direction_id())) service = self._get_organization_label(long(self.service_id())) site = self._get_organization_label(long(self.site_id())) subsite = self._get_organization_label(long(self.subsite_id())) users = self.user_repository.get_by_organization(corporation, direction, service, site, subsite, True) for user in users: user.fi_uid = self.uid flashmessage.set_flash(_(u'Entity assigned to the facilitator')) return True
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
def commit(self): if super(AvatarEditor, self).commit((), ('photo',)): user = self.user if self.photo.value: user.photo = self.photo.value flashmessage.set_flash(_(u'Avatar changed')) return True return False
def update_expert(self): properties = ('expert_email', 'comment') if super(EvaluationMenu, self).is_validated(properties): self.add_comment(self.expert_email.value, self.comment.value) flashmessage.set_flash(_(u'Expert added')) self.reset()
def update_di_business_area(self): if not super(DIEditor, self).commit((), ('di_business_area',)): return False self.user.di_business_area = self.di_business_area.value flashmessage.set_flash(_(u"Expert's business area updated")) return True
def commit(self): if not super(UserFIEditor, self).commit((), ('fi_uid',)): return False new_facilitator = self.user_repository.get_by_uid(self.fi_uid()) self.user.fi = new_facilitator flashmessage.set_flash(_(u'Facilitator changed')) return True
def commit(self): if not super(ResetPassword, self).commit((), ('login',)): return False uid = self.login.value password_reset_url = get_url_service().expand_url(['password_reset', uid], relative=False) ResetPasswordConfirmation(uid).send_email(password_reset_url) flashmessage.set_flash(_(u"A password reset email has been sent to your contact email address.")) return True
def update_context(self): properties = ('title', 'description', 'impact', 'benefit_department') if super(EvaluationMenu, self).is_validated(properties): self.data.title = self.title.value self.data.description = self.description.value self.data.impact = self.impact.value self.idea.benefit_department = self.benefit_department.value flashmessage.set_flash(_(u'Context changed')) self.reset()
def commit(self): if not super(PasswordEditor, self).commit( (), ('password', 'password_confirm')): return False # failure user = self.user user.change_password(self.password.value) security.get_manager().update_current_user_credentials() flashmessage.set_flash(_(u'Your password has been changed')) return True # success
def replace_facilitator(self): if not super(FIEditor, self).commit((), ('successor',)): return False # transfer the FI responsibilities to the new user new_facilitator = self.user_repository.get_by_uid(self.successor()) self.user.transfer_responsibilities(RoleType.Facilitator, new_facilitator) flashmessage.set_flash(_(u'Facilitator replaced')) return True
def update_potential(self): properties = ( 'innovation_scale', 'complexity_scale', 'duplicate', 'localization') if super(EvaluationMenu, self).is_validated(properties): self.data.innovation_scale = self.innovation_scale.value self.data.complexity_scale = self.complexity_scale.value self.data.duplicate = self.duplicate.value self.data.localization = self.localization.value flashmessage.set_flash(_(u'Potential changed')) self.reset()
def commit(self): if not super(ProfileEditor, self).commit(): # no property!? return False self.user.description = self.description.value self.user.competencies = self.competencies.value self.user.hobbies = self.hobbies.value self.user.expertises = self.expertises.value self.user.specialty = self.specialty.value self.user.work_phone = self.work_phone.value self.user.mobile_phone = self.mobile_phone.value flashmessage.set_flash(_(u'Your profile has been changed')) return True
def commit(self): if not super(ResetPassword, self).commit((), ('login', )): return False uid = self.login.value password_reset_url = get_url_service().expand_url( ['password_reset', uid], relative=False) ResetPasswordConfirmation(uid).send_email(password_reset_url) flashmessage.set_flash( _(u"A password reset email has been sent to your contact email address." )) return True
def vote(self, rate, user=None): user = user or get_current_user() if not security.has_permissions('vote_idea', self): flashmessage.set_flash( _("Sorry but you can't vote for this idea anymore")) return vote = self.find_vote(user) if not vote: self.i.vote(user, rate) elif user.is_dsig(): # a DSIG can cheat by voting more than once self.i.vote(user, rate + vote.rate) # accumulate the rates
def update_benefit(self): properties = ('financial_gain', 'customer_satisfaction', 'process_tier_down', 'public_image', 'environment_improvement', 'other_impact') if super(EvaluationMenu, self).is_validated(properties): self.data.financial_gain = self.financial_gain.value self.data.customer_satisfaction = self.customer_satisfaction.value self.data.process_tier_down = self.process_tier_down.value self.data.public_image = self.public_image.value self.data.environment_improvement = self.environment_improvement.value self.data.other_impact = self.other_impact.value flashmessage.set_flash(_(u'Benefit changed')) self.reset()
def update_domains(self): if not super(DIEditor, self).commit((), ('domains', )): return False user = self.user if user: domain_ids = [int(elt) for elt in self.domains.value] # FIXME: use the domain repository user.managed_domains = DomainData.query.filter( DomainData.id.in_(domain_ids)).all() flashmessage.set_flash(_(u'Domains changed')) return True
def update_benefit(self): properties = ( 'financial_gain', 'customer_satisfaction', 'process_tier_down', 'public_image', 'environment_improvement', 'other_impact') if super(EvaluationMenu, self).is_validated(properties): self.data.financial_gain = self.financial_gain.value self.data.customer_satisfaction = self.customer_satisfaction.value self.data.process_tier_down = self.process_tier_down.value self.data.public_image = self.public_image.value self.data.environment_improvement = self.environment_improvement.value self.data.other_impact = self.other_impact.value flashmessage.set_flash(_(u'Benefit changed')) self.reset()
def update_domains(self): if not super(DIEditor, self).commit((), ('domains',)): return False user = self.user if user: domain_ids = [int(elt) for elt in self.domains.value] # FIXME: use the domain repository user.managed_domains = DomainData.query.filter( DomainData.id.in_(domain_ids)).all() flashmessage.set_flash(_(u'Domains changed')) return True
def commit(self): if not self.is_validated(): return False category = self.category.value sign = self._find_sign(category) nb_points = self.points.value * sign reason = self.reason.value for email in self.users_emails.value: user = self.user_repository.get_by_email(email) user.add_points(category, nb_points, reason=reason) flashmessage.set_flash(_(u'Modifications done')) return True
def commit(self): current_user = security.get_user() assert current_user if not super(SubmitSuggestion, self).is_validated(('domain', 'content')): return False current_user = current_user.entity suggestion = self._create_suggestion(current_user, self.domain(), self.content()) self._send_email(suggestion) confirmation_message = _(u'Your suggestion has been sent to the IPS team') flashmessage.set_flash(confirmation_message) event_management._emit_signal(self, "VIEW_FRONTDESK") return True
def create_comment(self): if not self.is_valid(): return None # create the comment idea = self.idea content = self.content.value user = get_current_user() attachment = self.create_attachment(self.attachment.value) comment = idea.add_comment(user, content, attachment) # clear fields self.reset() flashmessage.set_flash(_(u'Comment added')) return comment
def commit(self): current_user = security.get_user() assert current_user if not super(SubmitSuggestion, self).is_validated( ('domain', 'content')): return False current_user = current_user.entity suggestion = self._create_suggestion(current_user, self.domain(), self.content()) self._send_email(suggestion) confirmation_message = _( u'Your suggestion has been sent to the IPS team') flashmessage.set_flash(confirmation_message) event_management._emit_signal(self, "VIEW_FRONTDESK") return True
def show_form(self, id): self.menu().selected(id) factory = self.choices[id][0]() elt_id, message, action = self.form.call(factory, model='form') if action in ['idea', 'direction']: if action == 'idea': idea = Idea(None, IdeaRepository().get_by_id(elt_id)) self.send_email_idea(idea) else: direction_label = get_direction_label(elt_id) self.send_email_direction(direction_label, message) flashmessage.set_flash(_( u'Your message has been sent. Thank you for your awareness !')) self.idea.goto()
def show_form(self, id): self.menu().selected(id) factory = self.choices[id][0]() elt_id, message, action = self.form.call(factory, model='form') if action in ['idea', 'direction']: if action == 'idea': idea = Idea(None, IdeaRepository().get_by_id(elt_id)) self.send_email_idea(idea) else: direction_label = get_direction_label(elt_id) self.send_email_direction(direction_label, message) flashmessage.set_flash( _(u'Your message has been sent. Thank you for your awareness !' )) self.idea.goto()
def commit(self): properties = ('subject', 'message') if not self.user: properties += ('sender_email',) if not self.is_validated(properties): return False # failure subject = _(u'Eureka : Contact (%s)') % self.subject() message = self.message() sender = self.user.email if self.user else self.sender_email.value mailer = mail.get_mailer() recipient = mailer.support_sender mailer.send_mail(subject, sender, [recipient], message) confirmation = _(u'Your request has been sent to the IPS team that will answer it as soon as possible') flashmessage.set_flash(confirmation) event_management._emit_signal(self, "VIEW_FRONTDESK") return True # success
def add_entity(self): if not super(FIEditor, self).commit( (), ('corporation_id', 'direction_id', 'service_id', 'site_id')): return False corporation = self._get_organization_label(long(self.corporation_id())) direction = self._get_organization_label(long(self.direction_id())) service = self._get_organization_label(long(self.service_id())) site = self._get_organization_label(long(self.site_id())) subsite = self._get_organization_label(long(self.subsite_id())) users = self.user_repository.get_by_organization( corporation, direction, service, site, subsite, True) for user in users: user.fi_uid = self.uid flashmessage.set_flash(_(u'Entity assigned to the facilitator')) return True
def commit(self): properties = ('subject', 'message') if not self.user: properties += ('sender_email', ) if not self.is_validated(properties): return False # failure subject = _(u'Eureka : Contact (%s)') % self.subject() message = self.message() sender = self.user.email if self.user else self.sender_email.value mailer = mail.get_mailer() recipient = mailer.support_sender mailer.send_mail(subject, sender, [recipient], message) confirmation = _( u'Your request has been sent to the IPS team that will answer it as soon as possible' ) flashmessage.set_flash(confirmation) event_management._emit_signal(self, "VIEW_FRONTDESK") return True # success
def update_evaluation(self): properties = ('innovation_scale', 'complexity_scale', 'duplicate', 'localization', 'goal', 'revenues_first_year', 'revenues_first_year_value', 'revenues_second_year', 'revenues_second_year_value', 'expenses_first_year', 'expenses_second_year') if super(EvaluationMenu, self).is_validated(properties): if self.target_date.value: self.data.target_date = datetime.strptime( self.target_date.value, '%d/%m/%Y') else: self.data.target_date = None self.data.goal = self.goal.value self.data.revenues_first_year = self.revenues_first_year.value self.data.revenues_first_year_value = self.revenues_first_year_value.value self.data.revenues_second_year = self.revenues_second_year.value self.data.revenues_second_year_value = self.revenues_second_year_value.value self.data.expenses_first_year = self.expenses_first_year.value self.data.expenses_first_year_value = self.expenses_first_year_value.value self.data.expenses_second_year = self.expenses_second_year.value self.data.expenses_second_year_value = self.expenses_second_year_value.value self.data.evaluation_impact = self.evaluation_impact.value flashmessage.set_flash(_(u'evaluation changed')) self.goal(self.data.goal) self.revenues_first_year(self.data.revenues_first_year) self.revenues_first_year_value(self.data.revenues_first_year_value) self.revenues_second_year(self.data.revenues_second_year) self.revenues_second_year_value( self.data.revenues_second_year_value) self.expenses_first_year_value(self.data.expenses_first_year_value) self.expenses_second_year(self.data.expenses_second_year) self.expenses_second_year_value( self.data.expenses_second_year_value) self.evaluation_impact(self.data.evaluation_impact) self.reset()
def update_evaluation(self): properties = ( 'innovation_scale', 'complexity_scale', 'duplicate', 'localization', 'goal', 'revenues_first_year', 'revenues_first_year_value', 'revenues_second_year', 'revenues_second_year_value', 'expenses_first_year', 'expenses_second_year') if super(EvaluationMenu, self).is_validated(properties): if self.target_date.value: self.data.target_date = datetime.strptime( self.target_date.value, '%d/%m/%Y') else: self.data.target_date = None self.data.goal = self.goal.value self.data.revenues_first_year = self.revenues_first_year.value self.data.revenues_first_year_value = self.revenues_first_year_value.value self.data.revenues_second_year = self.revenues_second_year.value self.data.revenues_second_year_value = self.revenues_second_year_value.value self.data.expenses_first_year = self.expenses_first_year.value self.data.expenses_first_year_value = self.expenses_first_year_value.value self.data.expenses_second_year = self.expenses_second_year.value self.data.expenses_second_year_value = self.expenses_second_year_value.value self.data.evaluation_impact = self.evaluation_impact.value flashmessage.set_flash(_(u'evaluation changed')) self.goal(self.data.goal) self.revenues_first_year(self.data.revenues_first_year) self.revenues_first_year_value(self.data.revenues_first_year_value) self.revenues_second_year(self.data.revenues_second_year) self.revenues_second_year_value(self.data.revenues_second_year_value) self.expenses_first_year_value(self.data.expenses_first_year_value) self.expenses_second_year(self.data.expenses_second_year) self.expenses_second_year_value(self.data.expenses_second_year_value) self.evaluation_impact(self.data.evaluation_impact) self.reset()
def replace_developer(self): if not super(DIEditor, self).commit((), ('successor', )): return False # prepare the content of the confirmation email assigned_ideas = IdeaRepository().get_assigned_to_developer(self.user) comment = '\n'.join( _('%(title)s: %(url)s') % dict(title=idea.title, url=self.idea_url(idea)) for idea in assigned_ideas) # transfer the DI responsibilities to the new user new_developer = self.user_repository.get_by_uid(self.successor()) self.user.transfer_responsibilities(RoleType.Developer, new_developer) # send the confirmation email mail_notification.send('mail-developer-replaced.html', to=new_developer, previous_di=self.user, comment=comment) flashmessage.set_flash(_(u'Expert replaced')) return True
def replace_developer(self): if not super(DIEditor, self).commit((), ('successor',)): return False # prepare the content of the confirmation email assigned_ideas = IdeaRepository().get_assigned_to_developer(self.user) comment = '\n'.join(_('%(title)s: %(url)s') % dict(title=idea.title, url=self.idea_url( idea)) for idea in assigned_ideas) # transfer the DI responsibilities to the new user new_developer = self.user_repository.get_by_uid(self.successor()) self.user.transfer_responsibilities(RoleType.Developer, new_developer) # send the confirmation email mail_notification.send('mail-developer-replaced.html', to=new_developer, previous_di=self.user, comment=comment) flashmessage.set_flash(_(u'Expert replaced')) return True
def untrack_idea(self): user = get_current_user() assert user user.untrack_idea(self.id) flashmessage.set_flash(_(u'Idea removed from tracking'))
def track_idea(self): user = get_current_user() assert user user.track_idea(self.id) flashmessage.set_flash(_(u'Idea added to tracking'))
def delete(self): # Need to use session.delete to trigger delete cascades session.delete(self.i) flashmessage.set_flash(_(u'Idea deleted')) event_management._emit_signal(self, "VIEW_IDEAS")
def delete_idea(self): self.idea.i.delete() flashmessage.set_flash(_(u'Idea deleted')) event_management._emit_signal(self, "VIEW_IDEAS")
def edit_user(self, comp): message = comp.call(UserEditor(self.uid, email_unique=self.email_unique, mobile_access=self.mobile_access)) self.reset() if message: flashmessage.set_flash(message)
def hide_event(self, event_id): self.user.hide_event(event_id) flashmessage.set_flash(_(u'Event removed'))
def remove_tracked_idea(self, idea_id): self.user.untrack_idea(idea_id) flashmessage.set_flash(_(u'Idea removed from tracking'))
def remove_point(self, point_id): PointData.get(point_id).delete() flashmessage.set_flash(_(u"Points deleted"))