Revision 1ca02d1a snf-astakos-app/astakos/im/views/im.py
b/snf-astakos-app/astakos/im/views/im.py | ||
---|---|---|
49 | 49 |
from django.core.exceptions import PermissionDenied |
50 | 50 |
from django.views.decorators.http import require_http_methods |
51 | 51 |
from django.utils import simplejson as json |
52 |
from django.template import RequestContext |
|
53 |
|
|
54 |
from synnefo_branding import utils as branding |
|
55 |
from synnefo_branding import settings as branding_settings |
|
52 | 56 |
|
53 | 57 |
from synnefo.lib import join_urls |
54 | 58 |
|
... | ... | |
62 | 66 |
from astakos.im.forms import LoginForm, InvitationForm, FeedbackForm, \ |
63 | 67 |
SignApprovalTermsForm, EmailChangeForm |
64 | 68 |
from astakos.im.forms import ExtendedProfileForm as ProfileForm |
69 |
from synnefo.lib.services import get_public_endpoint |
|
65 | 70 |
from astakos.im.functions import send_feedback, logout as auth_logout, \ |
66 | 71 |
invite as invite_func |
67 | 72 |
from astakos.im import settings |
... | ... | |
210 | 215 |
context_instance=context) |
211 | 216 |
|
212 | 217 |
|
218 |
|
|
213 | 219 |
@require_http_methods(["GET", "POST"]) |
214 | 220 |
@required_auth_methods_assigned() |
215 | 221 |
@login_required |
216 | 222 |
@cookie_fix |
217 | 223 |
@signed_terms_required |
224 |
def api_access_config(request, template_name='im/api_access_config.html', |
|
225 |
content_type='text/plain', extra_context=None, |
|
226 |
filename='.kamakirc'): |
|
227 |
|
|
228 |
if settings.KAMAKI_CONFIG_CLOUD_NAME: |
|
229 |
cloud_name = settings.KAMAKI_CONFIG_CLOUD_NAME |
|
230 |
else: |
|
231 |
cloud_name = branding_settings.SERVICE_NAME.replace(' ', '_').lower() |
|
232 |
|
|
233 |
url = get_public_endpoint(settings.astakos_services, 'identity') |
|
234 |
|
|
235 |
context = { |
|
236 |
'user': request.user, |
|
237 |
'services': Component.catalog(), |
|
238 |
'token_url': url, |
|
239 |
'cloud_name': cloud_name |
|
240 |
} |
|
241 |
|
|
242 |
extra_context = extra_context or {} |
|
243 |
context.update(extra_context) |
|
244 |
content = branding.render_to_string(template_name, context, |
|
245 |
RequestContext(request)) |
|
246 |
response = HttpResponse() |
|
247 |
response.status_code = 200 |
|
248 |
response.content_type = content_type |
|
249 |
response['Content-Disposition'] = 'attachment; filename="%s"' % filename |
|
250 |
response.content = content |
|
251 |
return response |
|
252 |
|
|
253 |
|
|
254 |
@required_auth_methods_assigned() |
|
255 |
@login_required |
|
256 |
@cookie_fix |
|
257 |
@signed_terms_required |
|
218 | 258 |
def api_access(request, template_name='im/api_access.html', |
219 | 259 |
extra_context=None): |
220 | 260 |
""" |
Also available in: Unified diff