def getTodaysExpense(self):
		import datetime
		from tuition.tools.models import Expenses
		from tuition.utils.manager import AppManager

		serializedObjects = []
		loggedInEmployee = AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email())
		today = datetime.date.today()
		todaysExpense = Expenses.all().filter('user ='******'dateOfExpense =', today).order('-dateOfExpense')
		todaysExpense = todaysExpense.fetch(limit=1000)
		for expense in todaysExpense:
			serializedObjects.append(expense.toDict)
		return self.respond(expenses=serializedObjects)
Example #2
0
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 getExpenseThisWeek(self):
		import datetime
		from tuition.tools.models import Expenses
		from tuition.utils.manager import AppManager
		from tuition.utils.utils import weekStartEnd

		serializedObjects = []
		loggedInEmployee = AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email())
		startOfWeek = weekStartEnd().get('start')
		thisWeeksExpense = Expenses.all().filter('user ='******'dateOfExpense >=', startOfWeek).order('-dateOfExpense')
		thisWeeksExpense = thisWeeksExpense.fetch(limit=1000)
		for expense in thisWeeksExpense:
			serializedObjects.append(expense.toDict)
		return self.respond(expenses=serializedObjects)
	def getExpenseOfYear(self, value):
		import datetime
		from tuition.tools.models import Expenses
		from tuition.utils.manager import AppManager
		from tuition.utils.appConstants import MONTH_NUM_FULL_NAME_DICT

		serializedList = []
		year = int(value.get('year', 2013))
		dateToCheck = datetime.date(year, 1, 1)
		loggedInEmployee = AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email())
		expenseOfTheYear = Expenses.all().filter('user ='******'dateOfExpense >=', dateToCheck).fetch(1000)
		for expense in expenseOfTheYear:
			serializedList.append(expense.toDict)
		return self.respond(expenses=serializedList)
	def getExpenseThisMonth(self, values):
		import datetime
		from tuition.tools.models import Expenses
		from tuition.utils.manager import AppManager
		from tuition.utils.utils import getMonthEnd

		serializedObjects = []
		year = int(values.get('year', 2013))
		month = int(values.get('month', datetime.date.today().month))
		loggedInEmployee = AppManager.getUserByEmail(AppManager.getCurrentLoggedInUser().email())
		firstOfMonth = datetime.date(year, month, 1)
		endOfMonth = datetime.date(year, month, getMonthEnd(month, year))
		thisMonthExpense = Expenses.all().filter('user ='******'dateOfExpense >=', firstOfMonth).filter('dateOfExpense <=', endOfMonth).order('-dateOfExpense')
		thisMonthExpense = thisMonthExpense.fetch(limit=1000)
		for expense in thisMonthExpense:
			serializedObjects.append(expense.toDict)
		return self.respond(expenses=serializedObjects)
Example #6
0
    def getTodaysExpense(self):
        import datetime
        from tuition.tools.models import Expenses
        from tuition.utils.manager import AppManager

        serializedObjects = []
        loggedInEmployee = AppManager.getUserByEmail(
            AppManager.getCurrentLoggedInUser().email())
        today = datetime.date.today()
        todaysExpense = Expenses.all().filter(
            'user ='******'dateOfExpense =',
                                           today).order('-dateOfExpense')
        todaysExpense = todaysExpense.fetch(limit=1000)
        for expense in todaysExpense:
            serializedObjects.append(expense.toDict)
        return self.respond(expenses=serializedObjects)
Example #7
0
    def getExpenseOfYear(self, value):
        import datetime
        from tuition.tools.models import Expenses
        from tuition.utils.manager import AppManager
        from tuition.utils.appConstants import MONTH_NUM_FULL_NAME_DICT

        serializedList = []
        year = int(value.get('year', 2013))
        dateToCheck = datetime.date(year, 1, 1)
        loggedInEmployee = AppManager.getUserByEmail(
            AppManager.getCurrentLoggedInUser().email())
        expenseOfTheYear = Expenses.all().filter(
            'user ='******'dateOfExpense >=',
                                                     dateToCheck).fetch(1000)
        for expense in expenseOfTheYear:
            serializedList.append(expense.toDict)
        return self.respond(expenses=serializedList)
Example #8
0
    def getExpenseThisWeek(self):
        import datetime
        from tuition.tools.models import Expenses
        from tuition.utils.manager import AppManager
        from tuition.utils.utils import weekStartEnd

        serializedObjects = []
        loggedInEmployee = AppManager.getUserByEmail(
            AppManager.getCurrentLoggedInUser().email())
        startOfWeek = weekStartEnd().get('start')
        thisWeeksExpense = Expenses.all().filter(
            'user ='******'dateOfExpense >=',
                                           startOfWeek).order('-dateOfExpense')
        thisWeeksExpense = thisWeeksExpense.fetch(limit=1000)
        for expense in thisWeeksExpense:
            serializedObjects.append(expense.toDict)
        return self.respond(expenses=serializedObjects)
Example #9
0
    def getExpenseThisMonth(self, values):
        import datetime
        from tuition.tools.models import Expenses
        from tuition.utils.manager import AppManager
        from tuition.utils.utils import getMonthEnd

        serializedObjects = []
        year = int(values.get('year', 2013))
        month = int(values.get('month', datetime.date.today().month))
        loggedInEmployee = AppManager.getUserByEmail(
            AppManager.getCurrentLoggedInUser().email())
        firstOfMonth = datetime.date(year, month, 1)
        endOfMonth = datetime.date(year, month, getMonthEnd(month, year))
        thisMonthExpense = Expenses.all().filter(
            'user ='******'dateOfExpense >=',
                firstOfMonth).filter('dateOfExpense <=',
                                     endOfMonth).order('-dateOfExpense')
        thisMonthExpense = thisMonthExpense.fetch(limit=1000)
        for expense in thisMonthExpense:
            serializedObjects.append(expense.toDict)
        return self.respond(expenses=serializedObjects)