def process_request(self, request): import logging from django import http from django.shortcuts import render_to_response from tuition.settings import SITE_DOWN_FOR_MAINTENANCE, SITE_DOWN_DESCRIPTION, SITE_SUPPORT_EMAIL from tuition.utils.manager import AppManager AppManager.setDomain(request.get_host()) if AppManager.isCurrentUserAppAdmin(): return None url = AppManager.isUserLoggedIn(request.path, request.path) if url: logging.info("User has not logged in through Google Accounts.") logging.info("Going to redirect user to %s." % url) return http.HttpResponseRedirect(url) user = AppManager.getCurrentLoggedInUser() if user: if SITE_DOWN_FOR_MAINTENANCE: return render_to_response( "siteDown.html", {"description": SITE_DOWN_DESCRIPTION, "supportEmail": SITE_SUPPORT_EMAIL} ) # implement any OAuth in future. if not AppManager.getUserByEmail(user.email()) and request.path not in SAFE_TO_REDIRECT_URI: logging.info("User has not registered yet.") logging.info("Going to redirect user to /register") return http.HttpResponseRedirect("/register?firstLogin=1") return None return None
def register(request): from tuition.settings import SITE_SUPPORT_EMAIL from forms import UserRegistrationForm from tuition.utils.manager import AppManager from tuition.utils.utils import URLCreator from tuition.urlPatterns import UrlPattern from tuition.utils.utils import GooglePlusService queryString = int(request.GET.get('firstLogin', 0)) loggedInEmployee = AppManager.getCurrentLoggedInUser() if not AppManager.isCurrentUserAppAdmin(): if not queryString or AppManager.getUserByEmail( AppManager.getCurrentLoggedInUser().email()): raise Exception('Unauthorized Access') else: loggedInEmployee = AppManager.getUserByEmail( AppManager.getCurrentLoggedInUser().email()) template_values = { 'form': UserRegistrationForm(), 'loggedInEmployee': loggedInEmployee, 'queryString': queryString } return render_to_response('userRegistration.html', template_values, context_instance=RequestContext(request))
def process_request(self, request): import logging from django import http from django.shortcuts import render_to_response from django.template import RequestContext from tuition.settings import SITE_DOWN_FOR_MAINTENANCE, SITE_DOWN_DESCRIPTION, SITE_SUPPORT_EMAIL from tuition.utils.manager import AppManager AppManager.setDomain(request.get_host()) if AppManager.isCurrentUserAppAdmin(): return None url = AppManager.isUserLoggedIn(request.path, request.path) if url: logging.info('User has not logged in.') logging.info('Going to redirect user to %s.' % url) return http.HttpResponseRedirect(url) user = AppManager.getCurrentLoggedInUser() if user: if SITE_DOWN_FOR_MAINTENANCE: return render_to_response( 'siteDown.html', {'description' : SITE_DOWN_DESCRIPTION}, context_instance=RequestContext(request) ) # implement any OAuth in future. if not AppManager.getUserByEmail(user.email()) and request.path not in SAFE_TO_REDIRECT_URI: logging.info('User has not registered yet.') logging.info('Going to redirect user to /register') return http.HttpResponseRedirect('/register?firstLogin=1') return None return None
def process_request(self, request): import logging from django import http from django.shortcuts import render_to_response from django.template import RequestContext from tuition.settings import SITE_DOWN_FOR_MAINTENANCE, SITE_DOWN_DESCRIPTION, SITE_SUPPORT_EMAIL from tuition.utils.manager import AppManager AppManager.setDomain(request.get_host()) if AppManager.isCurrentUserAppAdmin(): return None url = AppManager.isUserLoggedIn(request.path, request.path) if url: logging.info('User has not logged in.') logging.info('Going to redirect user to %s.' % url) return http.HttpResponseRedirect(url) user = AppManager.getCurrentLoggedInUser() if user: if SITE_DOWN_FOR_MAINTENANCE: return render_to_response( 'siteDown.html', {'description': SITE_DOWN_DESCRIPTION}, context_instance=RequestContext(request)) # implement any OAuth in future. if not AppManager.getUserByEmail( user.email()) and request.path not in SAFE_TO_REDIRECT_URI: logging.info('User has not registered yet.') logging.info('Going to redirect user to /register') return http.HttpResponseRedirect('/register?firstLogin=1') return None return None
def updateExpensesCreatedAndUpdatedOn(request): from tuition.tools.models import Expenses from tuition.utils.manager import AppManager from google.appengine.ext import db from django import http import datetime if not AppManager.isCurrentUserAppAdmin(): raise Exception('Unauthorized Access') isOver = False pageNo = int(request.GET.get('pageNo', 0)) expenses = Expenses.all().fetch(limit=60, offset=pageNo*60) if expenses: for expense in expenses: expense.createdOn = datetime.datetime.now() expense.updatedOn = datetime.datetime.now() db.put(expenses) pageNo += 1 else: isOver = True content = """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Update Expenses</title></head> <body style="font-size: 18px;"> <div style="text-align:center font-weight:bold"> Number of records processed in this run : %d <form action="/updateExpensesCreatedAndUpdatedOn" method="GET"> <input type="hidden" name="pageNo" value="%d" /> <input type=submit value="Next"/> </form> </div> </body> </html>""" % (len(expenses), pageNo) if isOver: content = """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Update Expenses</title></head> <body style="font-size: 18px;"> <div style="text-align:center font-weight:bold"> Updation Complete </div> </body> </html> """ response = http.HttpResponse() response.write(content) return response
def register(request): from tuition.settings import SITE_SUPPORT_EMAIL from forms import UserRegistrationForm from tuition.utils.manager import AppManager from tuition.utils.utils import URLCreator from tuition.urlPatterns import UrlPattern from tuition.utils.utils import GooglePlusService queryString = int(request.GET.get('firstLogin', 0)) loggedInEmployee = AppManager.getCurrentLoggedInUser() if not AppManager.isCurrentUserAppAdmin(): if not queryString or AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email()): raise Exception('Unauthorized Access') else: loggedInEmployee = AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email()) template_values = { 'form' : UserRegistrationForm(), 'loggedInEmployee' : loggedInEmployee, 'queryString' : queryString } return render_to_response('userRegistration.html', template_values, context_instance=RequestContext(request))
def register(request): from tuition.settings import SITE_SUPPORT_EMAIL from forms import UserRegistrationForm from tuition.utils.manager import AppManager from tuition.utils.utils import URLCreator from tuition.urlPatterns import UrlPattern from tuition.utils.utils import GooglePlusService queryString = int(request.GET.get("firstLogin", 0)) loggedInEmployee = AppManager.getCurrentLoggedInUser() if not AppManager.isCurrentUserAppAdmin(): if not queryString or AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email()): raise Exception("Unauthorized Access") else: loggedInEmployee = AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email()) template_values = { "form": UserRegistrationForm(), "loggedInEmployee": loggedInEmployee, "url": AppManager.createLogoutURL(), "homePage": "/", "supportEmail": SITE_SUPPORT_EMAIL, "queryString": queryString, } return render_to_response("userRegistration.html", template_values)