def get_context_data(self, **kwargs): m = MessageManager() message_id = self.kwargs["message_id"] context = super(DetailView, self).get_context_data(**kwargs) context["message"] = self.get_data() context["url1"] = m.get_url(message_id) return context
def get_context_data(self, **kwargs): context = super(MessageUserView, self).get_context_data(**kwargs) context['user'] = self.get_object() messager = MessageManager() template_data = messager.get_templates() context['template'] = json.dumps(template_data) return context
def get_context_data(self, **kwargs): context = super(MessageHostView, self).get_context_data(**kwargs) context["id"] = self.kwargs['id'] messager = MessageManager() template_data = messager.get_templates() context['template'] = json.dumps(template_data) return context
def handle(self, request, data): message_manager = MessageManager(); project_id = data.pop('id') try: message_manager.send_message_project(data['subject'], data['message'], project_id, data['template']) messages.success(request, _('Message for Project has been sent successfully.')) except Exception: messages.error(request, _('Unable to send message for the user.')) return True
def __init__(self, request, *args, **kwargs): super(MessageProjectForm, self).__init__(request, *args, **kwargs) message_manager = MessageManager() template_data = message_manager.get_templates() template_choices = [] for key in template_data.keys(): choice = (key, template_data[key]['name']) template_choices.append(choice) choices = ([('none', _("--Select Template--"))] + template_choices) self.fields['template'].choices = choices
def get_data(self): messages_table = [] message_obj = MessageManager() messages_list = message_obj.get_message_by_recipient(self.request.user.id) for messages in messages_list: message = user_messages( messages.id, messages.sender, messages.subject, messages.timestamp, messages.message, messages.read ) messages_table.append(message) return messages_table
def get_data(self): sent_data = [] message_manager = MessageManager() for message_data in message_manager.return_all_messages(): message_id = message_data['id'] subject = message_data['subject'] sent_to = message_data['type'] read = str(message_data['read']) + '/' + str(message_data['total']) sent_data.append(sent_messages(message_id, subject, sent_to, read)) return sent_data
def get_data(self): try: message_id = self.kwargs['message_id'] message_obj = MessageManager() message = message_obj.get_message_info(message_id) except Exception: redirect = reverse(self.redirect_url) exceptions.handle(self.request, _('Unable to retrieve details for ' 'message "%s".') % message_id, redirect=redirect) # Not all exception types handled above will result in a redirect. # Need to raise here just in case. raise exceptions.Http302(redirect) return message
def handle(self, request, data): message_manager = MessageManager(); user_id = data.pop('id') try: url = '' if(str(data['template']) != 'none' and str(data['instances']) != ''): template_url = message_manager.get_action_url(data['template']) url = data['instances'] + '/' + template_url message_manager.send_message_user(data['subject'], data['message'], user_id, url) messages.success(request, _('Message for User has been sent successfully.')) except Exception: messages.error(request, _('Unable to send message for the user.')) return True
def get_data(self): try: message_id = self.kwargs["message_id"] instance_id = self.kwargs["instance_id"] message_manager = MessageManager() message_manager.execute_suspend_action(str(instance_id)) # delete message after action except Exception: redirect = reverse(self.redirect_url) exceptions.handle( self.request, _("Unable to execute suspend action for " 'instance "%s".') % instance_id, redirect=redirect, ) # Not all exception types handled above will result in a redirect. # Need to raise here just in case. raise exceptions.Http302(redirect) return message_id
def __init__(self, request, *args, **kwargs): super(MessageUserForm, self).__init__(request, *args, **kwargs) message_manager = MessageManager() #init template choices template_data = message_manager.get_templates() template_choices = [] for key in template_data.keys(): choice = (key, template_data[key]['name']) template_choices.append(choice) all_choices = ([('none', _("--Select Template--"))] + template_choices) self.fields['template'].choices = all_choices #init instances choices user_id = kwargs['initial'].get('id', None) instances_dict = message_manager.get_instances_dict(user_id) instances_choices = [] for key in instances_dict.keys(): choice = (key, instances_dict[key]) instances_choices.append(choice) self.fields['instances'].choices = instances_choices
def get_data(self): try: message_id = self.kwargs["message_id"] instance_id = self.kwargs["instance_id"] message_manager = MessageManager() if message_manager.is_action_enable(message_id) == "T": message_manager.execute_snapshot_action(str(instance_id)) message_manager.disable_action(message_id) return True else: return False except Exception: redirect = reverse(self.redirect_url) exceptions.handle( self.request, _("Unable to execute snapshot action for " 'instance "%s".') % instance_id, redirect=redirect, ) # Not all exception types handled above will result in a redirect. # Need to raise here just in case. raise exceptions.Http302(redirect) return message_id
def delete(self, request, obj_id): message = MessageManager() message.delete_message(obj_id)
def delete(self, request, obj_id): m = MessageManager() m.delete_admin_message(obj_id)