def get_moderation(self, akey, user_profile, data, node, **kwargs): new_moderation = Moderation() new_moderation.akey = akey new_moderation.action = kwargs['action'] new_moderation.locale = get_language() new_moderation.path = node.get_url() new_moderation.related = node new_moderation.username = user_profile.username new_moderation.email = user_profile.email new_moderation.validated = user_profile.validated if kwargs['action'] == 'comment': new_moderation.subject = 'Nouveau commentaire' elif kwargs['action'] == 'review': new_moderation.subject = 'Nouvel avis' elif kwargs['action'] == 'discuss': new_moderation.subject = 'Nouveau message' return new_moderation
def create_proposal(self, request, user_profile, input_data, template_args, **kwargs): # create a moderation with the request # action and data and a proposal status mod = Moderation() mod.akey = user_profile.akey mod.email = user_profile.email mod.username = user_profile.username mod.locale = get_language() mod.subject = 'Wants to change' mod.message = 'Wants to change' mod.action = kwargs['action'] mod.data = json.dumps(input_data) mod.status = 'proposed' mod.path = kwargs['node'].path mod.related_id = kwargs['node'].id mod.visible = False mod.completed_date = now() mod.save() messages.warning(request, 'Your proposal have been posted !') return HttpResponseRedirect(kwargs['node'].get_url()+'view/')
def process_invite(self, request, user_profile, input_data, template_args, **kwargs): """ invite a group of user to join the commenting """ akey = self.get_session_user_keys(request) action_data = kwargs['pipe'] action = kwargs.get('action') emails = input_data.get('emails') # establish a list of invitation invitationList = {} # from email list if emails: for email in emails.split(','): invitationList[email] = None origin, = self.get_forms_instances(action, user_profile, kwargs) # for iemail in invitationList: invitation = Moderation() invitation.origin = origin invitation.related_id = template_args['currentNode'].id invitation.action = 'invite' invitation.locale = get_language() invitation.path = kwargs['node'].get_url() invitation.status = 'invited' invitation.email = iemail invitation.akey = get_new_uuid() invitation.subject = 'Invitation lancee !' invitation.message = input_data.get('message', 'Vous etes invite a consulter ce document') invitation.save() template_args['action_forms'] = self.get_validated_forms( self.get_forms_instances(action, user_profile, kwargs), input_data, action, save_forms=False, bound_forms=False ) return self.render(request, template_args, **kwargs)