mail: display mail note in summary (#10096)
This commit is contained in:
parent
1b21e15d07
commit
42e4c24cc1
|
@ -14,6 +14,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from django.contrib.contenttypes import generic
|
from django.contrib.contenttypes import generic
|
||||||
|
@ -82,6 +83,9 @@ class Mail(models.Model):
|
||||||
user_details = get_wcs_data('api/users/%s/' % self.contact_id)
|
user_details = get_wcs_data('api/users/%s/' % self.contact_id)
|
||||||
return user_details.get('user_display_name')
|
return user_details.get('user_display_name')
|
||||||
|
|
||||||
|
def html_note(self):
|
||||||
|
return re.sub(r'[\r?\n]+', '<br><br>', self.note, re.DOTALL)
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=Mail)
|
@receiver(post_save, sender=Mail)
|
||||||
def create_thumbnail(sender, instance, created, **kwargs):
|
def create_thumbnail(sender, instance, created, **kwargs):
|
||||||
|
|
|
@ -5,6 +5,21 @@
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{% if object.note %}
|
||||||
|
<p class="postit">
|
||||||
|
{{object.html_note|safe}}
|
||||||
|
</p>
|
||||||
|
<style>
|
||||||
|
p.postit {
|
||||||
|
background: rgba(241,231,103,1);
|
||||||
|
transform: rotate(2deg);
|
||||||
|
box-shadow: 3px 3px 3px #aaa;
|
||||||
|
padding: 1ex;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if object.associations.all|length > 1 %}
|
{% if object.associations.all|length > 1 %}
|
||||||
<strong>{% trans 'Mail with multiple formdata:' %}</strong>
|
<strong>{% trans 'Mail with multiple formdata:' %}</strong>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
@ -111,9 +110,9 @@ edit_note = login_required(csrf_exempt(EditNote.as_view()))
|
||||||
@login_required
|
@login_required
|
||||||
def note(request, *args, **kwargs):
|
def note(request, *args, **kwargs):
|
||||||
mail = Mail.objects.get(id=kwargs['pk'])
|
mail = Mail.objects.get(id=kwargs['pk'])
|
||||||
note = mail.note or '+'
|
if not mail.note:
|
||||||
note = re.sub(r'[\r?\n]+', '<br><br>', note, re.DOTALL)
|
mail.note = '+'
|
||||||
return HttpResponse(note)
|
return HttpResponse(mail.html_note())
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in New Issue