Пример #1
0
    def process_request(self, request):
        user = request.user

        if not user or not user.is_authenticated():
            return

        profile = get_profile(user)
        expires_after = AUTH.IDLE_SESSION_TIMEOUT.get()
        now = datetime.now()
        logout = False

        if profile.last_activity and expires_after > 0 and self._total_seconds(
                now - profile.last_activity) > expires_after:
            logout = True

        # Save last activity for user except when polling
        if not (request.path.strip('/') == 'jobbrowser/jobs'
                and request.POST.get('format')
                == 'json') and not (request.path == '/desktop/debug/is_idle'):
            try:
                profile.last_activity = datetime.now()
                profile.save()
            except DatabaseError:
                LOG.exception('Error saving profile information')

        if logout:
            dt_logout(request, next_page='/')
Пример #2
0
  def process_request(self, request):
    user = request.user

    if not user or not user.is_authenticated():
      return

    profile = get_profile(user)
    expires_after = AUTH.IDLE_SESSION_TIMEOUT.get()
    now = datetime.now()
    logout = False

    if profile.last_activity and expires_after > 0 and self._total_seconds(now - profile.last_activity) > expires_after:
      logout = True

    # Save last activity for user except when polling
    if not (request.path.strip('/') == 'notebook/api/check_status') \
        and not (request.path.strip('/').startswith('jobbrowser/api/job')) \
        and not (request.path.strip('/') == 'jobbrowser/jobs' and request.POST.get('format') == 'json') \
        and not (request.path.strip('/') == 'desktop/debug/is_idle') \
        and not (request.path.strip('/').startswith('oozie/list_oozie_')):
      try:
        profile.last_activity = datetime.now()
        profile.save()
      except DatabaseError:
        LOG.exception('Error saving profile information')

    if logout:
      dt_logout(request, next_page='/')
Пример #3
0
    def process_request(self, request):
        user = request.user

        if not user or not user.is_authenticated():
            return

        profile = get_profile(user)
        expires_after = AUTH.IDLE_SESSION_TIMEOUT.get()
        now = datetime.now()
        logout = False

        if (
            profile.last_activity
            and expires_after > 0
            and self._total_seconds(now - profile.last_activity) > expires_after
        ):
            logout = True

        # Save last activity for user except when polling
        if not (request.path.strip("/") == "jobbrowser/jobs" and request.POST.get("format") == "json") and not (
            request.path == "/desktop/debug/is_idle"
        ):
            try:
                profile.last_activity = datetime.now()
                profile.save()
            except DatabaseError:
                LOG.exception("Error saving profile information")

        if logout:
            dt_logout(request, next_page="/")
Пример #4
0
    def process_request(self, request):
        user = request.user

        if not user or not user.is_authenticated():
            return

        profile = get_profile(user)
        expires_after = AUTH.IDLE_SESSION_TIMEOUT.get()
        now = datetime.now()
        logout = False

        if profile.last_activity and expires_after > 0 and self._total_seconds(
                now - profile.last_activity) > expires_after:
            messages.info(
                request,
                _('Your session has been timed out due to inactivity.'))
            logout = True

        # Save last activity for user except when polling jobbrowser
        if not (request.path.strip('/') == 'jobbrowser'
                and request.GET.get('format') == 'json'):
            try:
                profile.last_activity = datetime.now()
                profile.save()
            except DatabaseError:
                LOG.exception('Error saving profile information')

        if logout:
            dt_logout(request, next_page='/')
Пример #5
0
  def process_request(self, request):
    user = request.user

    if not user or not user.is_authenticated():
      return

    profile = get_profile(user)
    expires_after = AUTH.IDLE_SESSION_TIMEOUT.get()
    now = datetime.now()
    logout = False

    if profile.last_activity and expires_after > 0 and self._total_seconds(now - profile.last_activity) > expires_after:
      messages.info(request, _('Your session has been timed out due to inactivity.'))
      logout = True

    # Save last activity for user except when polling jobbrowser
    if not (request.path.strip('/') == 'jobbrowser' and request.GET.get('format') == 'json'):
      try:
        profile.last_activity = datetime.now()
        profile.save()
      except DatabaseError:
        LOG.exception('Error saving profile information')

    if logout:
      dt_logout(request, next_page='/')
Пример #6
0
  def process_request(self, request):
    user = request.user

    if not user or not user.is_authenticated():
      return

    profile = get_profile(user)
    profile.last_activity = datetime.now()

    try:
      profile.save()
    except DatabaseError:
      log.exception('Error saving profile information')
Пример #7
0
    def process_request(self, request):
        user = request.user

        if not user or not user.is_authenticated():
            return

        profile = get_profile(user)
        profile.last_activity = datetime.now()

        try:
            profile.save()
        except DatabaseError:
            log.exception('Error saving profile information')
def view_profile(request):
    try:
        profile = get_profile(request.user)
        if profile is None:
            return HttpResponseRedirect("/logout/")
        profile_list = [(field.name, [getattr(profile, field.name), ])
                        for field in profile._meta.fields]
        return render_to_response('ldap_profile.html',
                                  {'profile': profile_list, },
                                  RequestContext(request))
    except (ObjectDoesNotExist):
        return HttpResponseRedirect("/logout/")
    except (MultipleObjectsReturned):
        return HttpResponseRedirect("/profile/ldap_error")
Пример #9
0
def view_profile(request):
    try:
        profile = get_profile(request.user)
        if profile is None:
            return HttpResponseRedirect("/logout/")
        profile_list = list()
        display_names = dict()
        for field_name, field in attribute_map.iteritems():
            name = field.get('profile_field_name', field_name)
            display_name = field.get('display_name', field_name)
            display_names.update({name: display_name})
        for field in profile._meta.fields:
            if field.name in display_names:
                label = display_names.get(field.name)
            else:
                label = field.name
            profile_list.append((label, getattr(profile, field.name)))
        return render_to_response('ldap_profile.html',
                                  {'profile': profile_list, },
                                  RequestContext(request))
    except (ObjectDoesNotExist):
        return HttpResponseRedirect("/logout/")
    except (MultipleObjectsReturned):
        return HttpResponseRedirect("/profile/ldap_error")
Пример #10
0
 def get_object(self):
     self.model = Profile
     self.form_class = forms.LdapProfileForm(self.request)
     return get_profile(self.request.user)
Пример #11
0
def index(request, template_name="home.html"):
    return render_to_response(template_name,
                              {'profile': get_profile()},
                              context_instance=RequestContext(request))