Esempio n. 1
0
def deactivate_profile_view(context, request):
    name = context.__name__
    myself = authenticated_userid(request) == context.__name__

    confirm = request.params.get('confirm')
    if confirm:
        try:
            find_users(context).remove(name)
        except KeyError:
            pass
        workflow = get_workflow(IProfile, 'security', context)
        workflow.transition_to_state(context, request, 'inactive')
        if myself:
            return logout_view(context, request, reason='User removed')
        query = {'status_message': 'Deactivated user account: %s' % name}
        parent = context.__parent__
        location = resource_url(parent, request, query=query)

        return HTTPFound(location=location)

    page_title = 'Deactivate user account for %s %s' % (context.firstname,
                                                        context.lastname)
    api = TemplateAPI(context, request, page_title)

    # Show confirmation page.
    return dict(api=api, myself=myself)
Esempio n. 2
0
def deactivate_profile_view(context, request):
    page_title = 'Deactivate user account for %s %s' % (context.firstname,
                                                        context.lastname)
    api = TemplateAPI(context, request, page_title)

    name = context.__name__
    myself = authenticated_userid(request) == context.__name__

    if not api.user_is_admin and not myself:
        raise Forbidden("Only owner or admin can deactivate profile")

    confirm = request.params.get('confirm')
    if confirm:
        try:
            find_users(context).remove(name)
        except KeyError:
            pass
        workflow = get_workflow(IProfile, 'security', context)
        workflow.transition_to_state(context, request, 'inactive')
        if myself:
            return logout_view(context, request, reason='User removed')
        query = {'status_message': 'Deactivated user account: %s' % name}
        parent = context.__parent__
        location = resource_url(parent, request, query=query)

        return HTTPFound(location=location)

    # Show confirmation page.
    return dict(api=api, myself=myself)
Esempio n. 3
0
def delete_profile_view(context, request):

    confirm = request.params.get('confirm')
    if confirm:
        parent = context.__parent__
        name = context.__name__
        find_users(context).remove(name)
        del parent[name]

        if authenticated_userid(request) == name:
            return logout_view(context, request, reason='User removed')
        query = {'status_message': 'Deleted profile: %s' % name}
        location = model_url(parent, request, query=query)

        return HTTPFound(location=location)

    page_title = 'Delete Profile for %s %s' % (context.firstname,
                                               context.lastname)
    api = TemplateAPI(context, request, page_title)

    # Get a layout
    return render_template_to_response(
        'templates/delete_profile.pt',
        api=api,
        )
Esempio n. 4
0
    def _callFUT(self, context, request, reason=_marker):
        from karl.views.login import logout_view

        if reason is not _marker:
            return logout_view(context, request, reason)
        return logout_view(context, request)
Esempio n. 5
0
 def _callFUT(self, context, request, reason=_marker):
     from karl.views.login import logout_view
     if reason is not _marker:
         return logout_view(context, request, reason)
     return logout_view(context, request)