def dashboard(request): if (timezone.now() - request.user.cookies.last_access) > timedelta(seconds=200): return HttpResponseRedirect('/login/') cookies = {request.user.cookies.key: request.user.cookies.value} s = SysacadSession(FR_BASE_URL[request.user.fr], cookies=cookies) materias = s.materiasEnCurso() return render_to_response('dashboard.html', RequestContext(request, {'materias': materias}))
def authenticate(self, fr=None, legajo=None, password=None): s = SysacadSession(FR_BASE_URL[fr]) try: s.login(legajo, password) except: return None try: alumno = Alumno.objects.get(fr=fr, legajo=legajo) except Alumno.DoesNotExist: alumno = Alumno.objects.create_user(fr, legajo) alumno.set_password(password) datos = s.datosAlumno() alumno.first_name = datos['nombre'] alumno.last_name = datos['apellido'] alumno.save() else: if not alumno.check_password(password): alumno.set_password(password) alumno.last_activity = timezone.now() alumno.cookies.last_access = timezone.now() alumno.cookies.key = s.cookies.keys()[0] alumno.cookies.value = s.cookies.values()[0] alumno.cookies.save() alumno.save() return alumno
def test_correct_login(self): sysacad = SysacadSession(BASE_URL) sysacad.login(LEGAJO, PASSWORD)
def setUp(self): sysacad = SysacadSession(BASE_URL) sysacad.login(LEGAJO, PASSWORD) self.estado_academico_data = sysacad.estado_academico_data() self.correlatividad_cursado_data = sysacad.correlatividad_cursado_data()