Revision 967b00bb

b/settings.d/30-ui.conf
16 16

  
17 17
# How often should the UI request changes from the API
18 18
UPDATE_INTERVAL = 5000
19

  
20
# List of emails used for sending the feedback messages to (following the ADMINS format)
21
FEEDBACK_CONTACTS = (
22
    # ('Contact Name', 'contact_email@domain.com'),
23
)
24

  
25
# Email from which the feedback emails will be sent from
26
FEEDBACK_EMAIL_FROM = SYSTEM_EMAIL_ADDR
b/ui/templates/feedback_mail.txt
1
Feedback message:
2
{{ message }}
3

  
4
User accepted data send:
5
{{ allow_data_send }}
6

  
7
User data:
8
{{ data|safe }}
9

  
b/ui/urls.py
1 1
# Copyright 2011 GRNET S.A. All rights reserved.
2
# 
2
#
3 3
# Redistribution and use in source and binary forms, with or
4 4
# without modification, are permitted provided that the following
5 5
# conditions are met:
6
# 
6
#
7 7
#   1. Redistributions of source code must retain the above
8 8
#      copyright notice, this list of conditions and the following
9 9
#      disclaimer.
10
# 
10
#
11 11
#   2. Redistributions in binary form must reproduce the above
12 12
#      copyright notice, this list of conditions and the following
13 13
#      disclaimer in the documentation and/or other materials
14 14
#      provided with the distribution.
15
# 
15
#
16 16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
......
25 25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 27
# POSSIBILITY OF SUCH DAMAGE.
28
# 
28
#
29 29
# The views and conclusions contained in the software and
30 30
# documentation are those of the authors and should not be
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33
# 
33
#
34 34
from django.conf.urls.defaults import *
35 35
import os
36 36

  
......
48 48
    url(r'^files$', 'synnefo.ui.views.files', name='files'),
49 49
    url(r'^desktops$', 'synnefo.ui.views.desktops', name='desktop'),
50 50
    url(r'^apps$', 'synnefo.ui.views.apps', name='apps'),
51
    url(r'^feedback$', 'synnefo.ui.views.feedback_submit', name='feedback'),
51 52
    url(r'^static/(.*)$', 'django.views.static.serve',
52 53
    {'document_root': os.path.join(os.path.dirname(__file__), 'static')}),
53 54
)
b/ui/views.py
39 39
from django.utils.translation import get_language
40 40
from django.utils import simplejson as json
41 41
from django.shortcuts import render_to_response
42
from django.template.loader import render_to_string
42 43
from django.core.urlresolvers import reverse
43 44

  
45
from synnefo.logic.email_send import send_async
46

  
44 47
TIMEOUT = settings.TIMEOUT
45 48
UPDATE_INTERVAL = settings.UPDATE_INTERVAL
46 49
IMAGE_ICONS = settings.IMAGE_ICONS
......
177 180

  
178 181
    return response
179 182

  
183
FEEDBACK_CONTACTS = getattr(settings, "FEEDBACK_CONTACTS", [])
184
FEEDBACK_EMAIL_FROM = settings.FEEDBACK_EMAIL_FROM
185

  
186
def feedback_submit(request):
187
    message = request.POST.get("feedback-msg")
188
    data = request.POST.get("feedback-data")
189

  
190
    # default to True (calls from error pages)
191
    allow_data_send = request.POST.get("feedback-submit-data", True)
192

  
193
    mail_subject = _("Feedback from synnefo application")
194

  
195
    mail_context = {'message': message, 'data': data, 'allow_data_send': allow_data_send, 'request': request}
196
    mail_content = render_to_string("feedback_mail.txt", mail_context)
197

  
198
    if settings.DEBUG:
199
        print mail_subject, mail_content
200

  
201
    for email in FEEDBACK_CONTACTS:
202
        send_async(
203
                frm = FEEDBACK_EMAIL_FROM,
204
                to = "%s <%s>" % (email[0], email[1]),
205
                subject = mail_subject,
206
                body = mail_content
207
        )
208

  
209
    return HttpResponse("ok");
180 210

  
181 211
def images(request):
182 212
    context = {}

Also available in: Unified diff