Commit b7be7267 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Auth providers add/remove messages

- Include provider method display
- Add remove message
parent 9bd227f4
......@@ -86,6 +86,7 @@ class AuthProvider(object):
logout_from_provider_text = None
icon_url = None
icon_medium_url = None
method_prompt = None
def get_message(self, msg, **kwargs):
params = kwargs
......@@ -145,6 +146,8 @@ class AuthProvider(object):
self.icon_medium_url = '%s%s' % (settings.MEDIA_URL, 'im/auth/icons-medium/%s.png' %
self.module.lower())
if not self.method_prompt:
self.method_prompt = _('%s login method') % self.get_title_display
def __getattr__(self, key):
if not key.startswith('get_'):
......@@ -234,6 +237,8 @@ class ShibbolethAuthProvider(AuthProvider):
login_prompt_template = 'im/auth/third_party_provider_generic_login_prompt.html'
logout_from_provider_text = ' at your Academic account (shibboleth)'
method_prompt = _('Academic credentials')
class TwitterAuthProvider(AuthProvider):
module = 'twitter'
......
......@@ -200,7 +200,8 @@ AUTH_PROVIDER_NOT_ACTIVE_FOR_LOGIN = "Login using '%(provider)s' is
AUTH_PROVIDER_NOT_ACTIVE_FOR_USER = "You cannot login using '%(provider)s'."
AUTH_PROVIDER_NOT_ACTIVE_FOR_CREATE = "Sign up using '%(provider)s' is disabled."
AUTH_PROVIDER_NOT_ACTIVE_FOR_ADD = "You cannot add %(provider)s login method."
AUTH_PROVIDER_ADDED = "New login method added successfully."
AUTH_PROVIDER_ADDED = "%s enabled for this account."
AUTH_PROVIDER_REMOVED = "%s removed for this account."
AUTH_PROVIDER_ADD_FAILED = "Failed to add new login method."
AUTH_PROVIDER_ADD_EXISTS = "It seems that this account is already assigned to another user."
AUTH_PROVIDER_LOGIN_TO_ADD = "The new login method will be assigned once you login to your account."
......
......@@ -160,7 +160,9 @@ def handle_third_party_login(request, provider_module, identifier,
user.add_auth_provider(provider_module, identifier=identifier,
affiliation=affiliation,
provider_info=provider_info)
messages.success(request, astakos_messages.AUTH_PROVIDER_ADDED)
provider = auth_providers.get_provider(provider_module)
message = _(astakos_messages.AUTH_PROVIDER_ADDED) % provider.get_method_prompt_display
messages.success(request, message)
return HttpResponseRedirect(reverse('edit_profile'))
# astakos user exists ?
......
......@@ -904,6 +904,9 @@ def remove_auth_provider(request, pk):
if provider.can_remove():
provider.delete()
message = astakos_messages.AUTH_PROVIDER_REMOVED % \
provider.settings.get_method_prompt_display
messages.success(request, message)
return HttpResponseRedirect(reverse('edit_profile'))
else:
raise PermissionDenied
......@@ -1226,14 +1229,14 @@ def project_search(request):
projects = ProjectApplication.objects.search_by_name(q)
projects = projects.filter(~Q(project__last_approval_date__isnull=True))
projects = projects.exclude(project__in=accepted_projects)
table = tables.UserProjectApplicationsTable(projects, user=request.user,
prefix="my_projects_")
if request.method == "POST":
table.caption = _('SEARCH RESULTS')
else:
table.caption = _('ALL PROJECTS')
RequestConfig(request, paginate={"per_page": PAGINATE_BY}).configure(table)
return object_list(
......@@ -1388,8 +1391,8 @@ def landing(request):
'im/landing.html',
context_instance=get_context(request))
def api_access(request):
return render_response(
'im/api_access.html',
context_instance=get_context(request))
\ No newline at end of file
context_instance=get_context(request))
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