Commit 9ead2622 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Delegate cyclades ui feedback calls to astakos

Mimic pithos app/ui feedback handling to avoid duplicating boilerplate
code.

New settings:
CYCLADES_USER_FEEDBACK_URL

Deprecated (removed) settings:
FEEDBACK_CONTACTS
FEEDBACK_EMAIL_FROM
parent db901b28
......@@ -256,6 +256,7 @@ def __send_feedback(request, email_template_name='im/feedback_mail.txt', user=No
form = FeedbackForm(request.POST)
if not form.is_valid():
logger.error("Invalid feedback request: %r", form.errors)
raise BadRequest('Invalid data')
msg = form.cleaned_data['feedback_msg']
......
......@@ -131,3 +131,6 @@
# endpoints. Set this to False if you deploy cyclades-app/astakos-app on the
# same machine.
#CYCLADES_PROXY_USER_SERVICES = True
#
## Astakos feedback endpoint.
#CYCLADES_USER_FEEDBACK_URL = 'https://accounts.example.synnefo.org/feedback'
......@@ -42,14 +42,6 @@
## How often to check for user usage changes
#UI_QUOTAS_UPDATE_INTERVAL = 10000
#
## List of emails used for sending the feedback messages to (following the ADMINS format)
#FEEDBACK_CONTACTS = (
# # ('Contact Name', 'contact_email@domain.com'),
#)
#
## Email from which the feedback emails will be sent from
#FEEDBACK_EMAIL_FROM = "~okeanos <no-reply@grnet.gr>"
#
## URL to redirect not authenticated users
#UI_LOGIN_URL = "/im/login"
#
......@@ -210,4 +202,3 @@
# 'admin@synnefo.gr': 'system',
# 'images@synnefo.gr': 'system'
#}
#
......@@ -71,6 +71,7 @@ def proxy(request, url, headers={}, body=None):
@csrf_exempt
def delegate_to_feedback_service(request):
logger.debug("Delegate feedback request to %s" % USER_FEEDBACK_URL)
token = request.META.get('HTTP_X_AUTH_TOKEN')
headers = {'X-Auth-Token': token}
return proxy(request, USER_FEEDBACK_URL, headers=headers,
......
......@@ -131,3 +131,6 @@ CYCLADES_USER_CATALOG_URL = 'https://<astakos domain>/user_catalogs'
# endpoints. Set this to False if you deploy cyclades-app/astakos-app on the
# same machine.
CYCLADES_PROXY_USER_SERVICES = True
# Astakos user_catalogs endpoint
CYCLADES_USER_FEEDBACK_URL = 'https://accounts.example.synnefo.org/feedback'
......@@ -42,14 +42,6 @@ UI_CHANGES_SINCE_ALIGNMENT = 0
# How often to check for user usage changes
UI_QUOTAS_UPDATE_INTERVAL = 10000
# List of emails used for sending the feedback messages to (following the ADMINS format)
FEEDBACK_CONTACTS = (
# ('Contact Name', 'contact_email@domain.com'),
)
# Email from which the feedback emails will be sent from
FEEDBACK_EMAIL_FROM = "~okeanos <no-reply@grnet.gr>"
# URL to redirect not authenticated users
UI_LOGIN_URL = "/im/login"
......@@ -211,3 +203,5 @@ UI_SYSTEM_IMAGES_OWNERS = {
'images@synnefo.gr': 'system'
}
# Astakos feedback endpoint. UI uses this setting to post error feedbacks
CYCLADES_USER_FEEDBACK_URL = 'https://accounts.synnefo.org/feedback'
......@@ -108,12 +108,12 @@
var extra = extra || {};
var data = {
'feedback-msg': msg,
'feedback-data': this.get_feedback_data() || ""
'feedback_msg': msg,
'feedback_data': this.get_feedback_data() || ""
}
var opts = {
'url': 'feedback',
'url': synnefo.config.feedback_post_url,
'data': $.param(data),
'success': this.show_success,
'error': this.show_error,
......
......@@ -104,8 +104,6 @@
var SKIP_TIMEOUTS = {{ skip_timeouts }};
var UPDATE_INTERVAL = {{ update_interval }};
var APP_DEBUG = {% if DEBUG %}true{% else %}false{% endif %};
var FEEDBACK_URL = "{% url ui_feedback %}";
var FEEDBACK_TITLE = "{% trans "Send feedback" %}";
var API_OVERLAY_TITLE = "{% trans "API access" %}";
var API_OVERLAY_SUBCONTENT = "{% trans "The API key provides full access to your <em>~okeanos</em> account, so always keep it private." %}";
......@@ -633,6 +631,7 @@
synnefo.config.machines_icons_url = '{{ SYNNEFO_IMAGES_URL }}icons/machines/';
synnefo.config.support_ssh_os_list = {{ support_ssh_os_list|safe }};
synnefo.config.os_created_users = {{ os_created_users|safe }};
synnefo.config.feedback_post_url = {{ feedback_post_url|safe }};
synnefo.config.logout_redirect = '{{ logout_redirect }}';
synnefo.config.login_redirect = '{{ login_redirect }}';
......@@ -676,6 +675,8 @@
synnefo.config.system_images_owners = {{ system_images_owners|safe }};
synnefo.ui.init();
synnefo.ui.main.bind("ready", function(){
synnefo.ui.trigger_error("test123");
});
})
......
......@@ -37,7 +37,6 @@ import os
urlpatterns = patterns('',
url(r'^$', 'synnefo.ui.views.home', name='ui_index'),
url(r'^feedback$', 'synnefo.ui.views.feedback_submit', name='ui_feedback'),
url(r'^userquota$', 'synnefo.ui.views.user_quota', name='ui_userquota'),
url(r'userdata/', include('synnefo.ui.userdata.urls'))
)
......
......@@ -126,8 +126,6 @@ UI_SYNNEFO_JS_WEB_URL = getattr(settings,
# extensions
ENABLE_GLANCE = getattr(settings, 'UI_ENABLE_GLANCE', True)
GLANCE_API_URL = getattr(settings, 'UI_GLANCE_API_URL', '/glance')
FEEDBACK_CONTACTS = getattr(settings, "FEEDBACK_CONTACTS", [])
FEEDBACK_EMAIL_FROM = settings.FEEDBACK_EMAIL_FROM
DIAGNOSTICS_UPDATE_INTERVAL = getattr(settings,
'UI_DIAGNOSTICS_UPDATE_INTERVAL', 2000)
......@@ -151,6 +149,7 @@ GROUP_PUBLIC_NETWORKS = getattr(settings, 'UI_GROUP_PUBLIC_NETWORKS', True)
GROUPED_PUBLIC_NETWORK_NAME = getattr(settings, 'UI_GROUPED_PUBLIC_NETWORK_NAME', 'Internet')
USER_CATALOG_URL = getattr(settings, 'UI_USER_CATALOG_URL', '/user_catalogs')
FEEDBACK_POST_URL = getattr(settings, 'UI_FEEDBACK_POST_URL', '/feedback')
TRANSLATE_UUIDS = not getattr(settings, 'TRANSLATE_UUIDS', False)
def template(name, request, context):
......@@ -177,6 +176,7 @@ def home(request):
'current_lang': get_language() or 'en',
'compute_api_url': json.dumps(COMPUTE_API_URL),
'user_catalog_url': json.dumps(USER_CATALOG_URL),
'feedback_post_url': json.dumps(FEEDBACK_POST_URL),
'translate_uuids': json.dumps(TRANSLATE_UUIDS),
# update interval settings
'update_interval': UPDATE_INTERVAL,
......@@ -186,7 +186,6 @@ def home(request):
'update_interval_max': UPDATE_INTERVAL_MAX,
'changes_since_alignment': CHANGES_SINCE_ALIGNMENT,
'quotas_update_interval': QUOTAS_UPDATE_INTERVAL,
# additional settings
'image_icons': IMAGE_ICONS,
'logout_redirect': LOGOUT_URL,
'login_redirect': LOGIN_URL,
......@@ -429,30 +428,3 @@ def machines_connect(request):
return response
def feedback_submit(request):
if not request.method == "POST":
raise Http404
# fill request object with astakos user information
get_user(request, settings.ASTAKOS_URL)
message = request.POST.get("feedback-msg")
data = request.POST.get("feedback-data")
if isinstance(request.user.get('email'), list):
email = request.user.get('email')[0]
else:
email = request.user.get('email')
# default to True (calls from error pages)
allow_data_send = request.POST.get("feedback-submit-data", True)
mail_subject = unicode(_("Feedback from synnefo application"))
mail_context = {'message': message, 'data': data, 'email': email,
'allow_data_send': allow_data_send, 'request': request}
mail_content = render_to_string("feedback_mail.txt", mail_context)
send_mail(mail_subject, mail_content, FEEDBACK_EMAIL_FROM,
dict(FEEDBACK_CONTACTS).values(), fail_silently=False)
return HttpResponse('{"status":"send"}')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment