Example #1
0
def submit_newcourse():
    """ create new course """
    #print_debug('submit_newcourse: {}'.format(request.form))
    name = request.form['name']  # e.g. "Intro Programming"
    path = request.form[
        'path']  # should have form term/folder e.g. fall2018/cs1
    copyfrom = request.form['copyfrom']  # e.g. "fall2017/cs1"
    startdate = path_to_startdate(path)
    title = name_to_htmltitle(name)
    print_debug(' submit_newcourse: name = "{}"'.format(name))
    print_debug('                   path = "{}"'.format(path))
    print_debug('                   copyfrom = "{}"'.format(copyfrom))
    newcourse = Course.create_course(name,
                                     path,
                                     start=startdate,
                                     name_as_title=title,
                                     copyfrom=copyfrom)
    for name in request.form['faculty'].split(','):
        try:
            faculty = Person.get(username=name.strip())
        except:
            faculty = None
        if not faculty:
            try:
                faculty = Person.get(username=name.strip())
            except:
                faculty = None
        if faculty:
            today = str(Time())[:10]
            newcourse.enroll(faculty, 'faculty', today, create_work=False)
    return newcourse.url
Example #2
0
def ReceiptSearch(self, PersonID=None, **kw):
	receipts = []
	if PersonID:
		try:
			person = Person.get(int(PersonID))
			customer = person.Customer[0]
			for receipt in customer.Receipts:
				receipts.append((receipt.id, '%d Items purchased on %s (%s)' % (receipt.CountPurchasedItems(), receipt.ModifyTime.strftime(DATE_FORMAT), receipt.StatusText()), receipt.TotalPaymentCalc()))
		except:
			log.debug("No receipts for person")
	return dict(headers = ['id','Description','Total'], rows=receipts)
Example #3
0
def PaymentSearch(self, PersonID=None, **kw):
	payments = []
	if PersonID:
		try:
			person = Person.get(int(PersonID))
			customer = person.Customer[0]
			log.debug("Payments count %d" % len(customer.Payments))
			for payment in customer.Payments:
				payments.append((payment.id, '%s on %s' % (payment.Type(), payment.DatePaid.strftime(DATE_FORMAT)), payment.Amount))
		except:
			log.debug("No payments for person")
	return dict(payments=payments)