Ejemplo n.º 1
0
def delete_from_my_messages(request, message_id):
    message = message_history_mdl.find_by_id(message_id)
    person_user = mdl.person.find_by_user(request.user)
    if message and (message.receiver_id == person_user.id):
        message_history_mdl.delete_my_messages([
            message_id,
        ])
    return HttpResponseRedirect(reverse('my_messages'))
Ejemplo n.º 2
0
def my_messages_action(request):
    my_message_action_form = MyMessageActionForm(request.POST)
    my_messages_formset = formset_factory(MyMessageForm)(request.POST, request.FILES)
    if my_message_action_form.is_valid() and my_messages_formset.is_valid():
        my_messages_ids_to_action = [mess_form.cleaned_data.get('id')
                                     for mess_form in my_messages_formset
                                     if mess_form.cleaned_data.get('selected')]
        if 'MARK_AS_READ' in my_message_action_form.cleaned_data.get('action'):
            message_history_mdl.mark_as_read(my_messages_ids_to_action)
        elif 'DELETE' in my_message_action_form.cleaned_data.get('action'):
            message_history_mdl.delete_my_messages(my_messages_ids_to_action)
    return HttpResponseRedirect(reverse('my_messages'))