def starting(request): """ Getting Started view for the Aristotle Library Apps project :param request: Web request from client :rtype: Generated HTML template """ return direct_to_template(request, 'getting-started.html', {'app':None, 'steps':[rst_loader.get('installing')], 'institution':json_loader.get('institution'), 'navbar_menus':json_loader.get('navbar-menus'), 'user':None})
def background(request): """ Background view for the Aristotle Library Apps project :param request: Web request from client :rtype: Generated HTML template """ return direct_to_template(request, 'background.html', {'app':None, 'history':rst_loader.get('project-history'), 'institution':json_loader.get('institution'), 'navbar_menus':json_loader.get('navbar-menus'), 'related_resources':rst_loader.get('related-resources'), 'user':None})
def default(request): """ Default view for Aristotle Library Apps project :param request: Web request from client :rtype: Generated HTML template """ app_listing = [] return direct_to_template(request, 'index.html', {'app':None, 'institution':json_loader.get('institution'), 'navbar_menus':json_loader.get('navbar-menus'), 'portfolio':app_listing, 'vision':rst_loader.get('vision-for-aristotle-library-apps'), 'user':None})
def app_login(request): """ Attempts to authenticate a user to Aristotle Library Apps :param request: HTTP Request """ if request.method == 'GET': return HttpResponse("IN GET App Login") username = request.POST['username'] password = request.POST['password'] next_page = request.REQUEST.get('next') errors = [] try: user = authenticate(last_name=username, iii_id=password) except KeyError: user = None if user is not None: if user.is_active: login(request, user) if len(next_page) > 0: return redirect(next_page) else: return redirect('/apps') else: error_msg = "User not active" logger.error(error_msg) errors.append(error_msg) else: error_msg = "User {0} not found or unable to authenticate".format(username) logger.error(error_msg) errors.append(error_msg) auth_form = AuthenticationForm(request.POST) auth_form.full_clean() auth_form._errors[NON_FIELD_ERRORS] = auth_form.error_class(errors) return direct_to_template(request, 'registration/login.html', {'app':None, 'institution':json_loader.get('institution'), 'form': auth_form, 'navbar_menus':json_loader.get('navbar-menus'), 'user':user})