Beispiel #1
0
def add_deadline(context, request):
    logged_in = authenticated_userid(request)
    main = get_renderer('../templates/master.pt').implementation()
    schema = DeadlineSchema()
    deadlineform = Form(schema, buttons=('submit',),use_ajax=True)
    if 'dateDue' in request.params:
        try:
            controls = request.POST.items()
            captured = deadlineform.validate(controls)
        except deform.ValidationFailure, e:
            deadlineform = e.render()
            return {'red':'',
                    'main':main, 
                    'form':deadlineform, 
                    'content':'',
                    'logged_in':logged_in,
                    'name':'Add Deadline'}
        dateDue = calendarstuff.datetime_from_str(request.params['dateDue'])
        hours = request.params['hours']
        sponsored = request.params['sponsored']
        appliedClass = request.params['appliedClass']
        context.count += 1
        deadline = Deadline(dateDue,hours,sponsored,appliedClass,context.count)
        deadline.__parent__ = context
        context[str(context.count)] = deadline
        find_root(context)['activityLogs'].deadline_creation(find_root(request.context)["users"][logged_in],deadline,request.application_url)
        return {'red':'deadlines/',
                'main':main,
                'form':'',
                'content':"Added a Deadline",
                'logged_in':logged_in,
                'name':'Redirecting...'}
Beispiel #2
0
def add_sponsored_event(context,request):
    logged_in = authenticated_userid(request)
    user = find_root(request.context)['users'][logged_in]
    main = get_renderer('../templates/master.pt').implementation()
    projectList = find_root(context)["settings"].projects
    projectTupleList = []
    for project in projectList:
        projectTupleList.append((project,project))
    projectTupleTuple=tuple(projectTupleList)   #sorry about this.  It was more fun than a ListList
    class SponsoredEventSchema(colander.MappingSchema):
        completionDate = colander.SchemaNode(colander.Date(),title="Completion Date (YYYY-MM-DD): ")
        hours = colander.SchemaNode(colander.Float(), title="Number of Hours: ")
        description = colander.SchemaNode(
                colander.String(),
                validator=colander.OneOf([x[0] for x in projectTupleTuple]),
                widget=deform.widget.RadioChoiceWidget(values=projectTupleTuple),
                title='Project',
                description='Select a Project')
        taskDescription = colander.SchemaNode(
                    colander.String(), title="Description: ",
                    widget=deform.widget.TextAreaWidget(rows=5, cols=40),
                    description='Enter some text')
        contact = colander.SchemaNode(colander.String(),title="Contact Name: ")
        contactInfo = colander.SchemaNode(colander.String(),title="Contact Info: ")
    schema=SponsoredEventSchema()
    eventform = Form(schema, buttons=('submit',))
    if 'taskDescription' in request.params:
        try:
            controls = request.POST.items()
            captured = eventform.validate(controls)
        except deform.ValidationFailure, e:
            eventform = e.render()
            return {'red':'',
                    'main':main, 
                    'form':eventform, 
                    'content':'',
                    'logged_in':logged_in,
                    'name':'Add Sponsored Event',
		    'TutText': getTutText(user, view='')}
        completionDate = calendarstuff.datetime_from_str(request.params['completionDate'])
        hours = request.params['hours']
        description = request.params['deformField3']
        taskDescription = request.params['taskDescription']
        contact = request.params['contact']
        contactInfo = request.params['contactInfo']
        context.eventcount += 1
        user = context.user
        event = Event("Sponsored","N/A",completionDate,hours,description,taskDescription,contact,contactInfo,user,context.eventcount)
        event.__parent__ = context
        context[str(context.eventcount)] = event
        activitylog = find_root(context)['activityLogs']
        activitylog.event_creation(find_root(request.context)["users"][logged_in],event,request.application_url)
        return {'red':'serviceLogs/'+context.user.username,
                'main':main,
                'form':'',
                'content':"Added sponsored event for "+description,
                'logged_in':logged_in,
                'name':'Redirecting...',
		'TutText': getTutText(user, view='')}
Beispiel #3
0
def add_independent_event(context, request):
    logged_in = authenticated_userid(request)
    main = get_renderer("../templates/master.pt").implementation()
    schema = IndependentEventSchema()
    eventform = Form(schema, buttons=("submit",))
    if "description" in request.params:
        try:
            controls = request.POST.items()
            captured = eventform.validate(controls)
        except deform.ValidationFailure, e:
            eventform = e.render()
            return {
                "red": "",
                "main": main,
                "form": eventform,
                "content": "",
                "logged_in": logged_in,
                "name": "Add Independent Event",
            }
        completionDate = calendarstuff.datetime_from_str(request.params["completionDate"])
        hours = request.params["hours"]
        description = request.params["description"]
        taskDescription = request.params["taskDescription"]
        contact = request.params["contact"]
        contactInfo = request.params["contactInfo"]
        affects = request.params["affects"]
        context.eventcount += 1
        user = context.user
        event = Event(
            "Independent",
            completionDate,
            hours,
            description,
            taskDescription,
            contact,
            contactInfo,
            user,
            context.eventcount,
            affects=affects,
        )
        event.__parent__ = context
        context[str(context.eventcount)] = event
        activitylog = find_root(context)["activityLogs"]
        activitylog.event_creation(find_root(request.context)["users"][logged_in], event, request.application_url)
        return {
            "red": "serviceLogs/" + context.user.username,
            "main": main,
            "form": "",
            "content": "Added independent event for " + description,
            "logged_in": logged_in,
            "name": "Redirecting...",
        }
Beispiel #4
0
def add_independent_event(context,request):
    logged_in = authenticated_userid(request)
    user = find_root(request.context)['users'][logged_in]
    main = get_renderer('../templates/master.pt').implementation()
    schema = IndependentEventSchema()
    eventform = Form(schema, buttons=('submit',))
    if 'description' in request.params:
        try:
            controls = request.POST.items()
            captured = eventform.validate(controls)
        except deform.ValidationFailure, e:
            eventform = e.render()
            return {'red':'',
                    'main':main, 
                    'form':eventform, 
                    'content':'',
                    'logged_in':logged_in,
                    'name':'Add Independent Event',
		    'TutText': getTutText(user, view='')}
        completionDate = calendarstuff.datetime_from_str(request.params['completionDate'])
        hours = request.params['hours']
        description = request.params['description']
        taskDescription = request.params['taskDescription']
        contact = request.params['contact']
        contactInfo = request.params['contactInfo']
        affects = request.params['affects']
	type = request.params['type']
        context.eventcount += 1
        user = context.user
        event = Event("Independent",
                      type,
                      completionDate,
                      hours,
                      description,
                      taskDescription,
                      contact,contactInfo,
                      user,
                      context.eventcount,
                      affects=affects)
        event.__parent__ = context
        context[str(context.eventcount)]=event
        activitylog=find_root(context)['activityLogs']
        activitylog.event_creation(find_root(request.context)["users"][logged_in],event,request.application_url)
        return {'red':'serviceLogs/'+context.user.username,
                'main':main,
                'form':'',
                'content':"Added independent event for "+description,
                'logged_in':logged_in,
                'name':'Redirecting...',
		'TutText': getTutText(user, view='')}
Beispiel #5
0
def edit_deadline(context,request):
    logged_in = authenticated_userid(request)
    user = find_root(request.context)['users'][logged_in]
    main = get_renderer('../templates/master.pt').implementation()
    schema = DeadlineEditSchema()
    deadlineform = Form(schema, buttons=('submit',),use_ajax=True)
    if 'dateDue' in request.params:
        try:
            controls = request.POST.items()
            captured = deadlineform.validate(controls)
        except deform.ValidationFailure, e:
            deadlineform = e.render()
            return {'red':'',
                    'main':main, 
                    'form':deadlineform, 
                    'content':'',
                    'logged_in':logged_in,
                    'name':'Edit Deadline',
		    'TutText': getTutText(user, view='')}
        if ('delete' in request.params) and (request.params['delete'] == "true"):
            activityLog = find_root(context)['activityLogs']
            activityLog.deadline_deletion(find_root(request.context)["users"][logged_in],context,request.application_url)
            del context.__parent__[str(context.ID)]
            return {'red':'deadlines/',
                    'main':main,
                    'name':'Redirecting...', 
                    'form':'',
                    'content':"Deleted this deadline",
                    'logged_in':logged_in,
		    'TutText': getTutText(user, view='')}
        dateDue = calendarstuff.datetime_from_str(request.params['dateDue'])
        context.hours = request.params['hours']
        context.sponsored = request.params['sponsored']
        context.appliedClass = request.params['appliedClass']
        activityLog=find_root(context)['activityLogs']
        activityLog.deadline_edit(find_root(request.context)["users"][logged_in],context,request.application_url)
        return {'red':'deadlines/',
                'main':main,
                'form':'',
                'content':"Edited the Deadline",
                'logged_in':logged_in,
                'name':'Redirecting...',
		'TutText': getTutText(user, view='')}
Beispiel #6
0
def edit_event(context,request):
    logged_in = authenticated_userid(request)
    user = find_root(request.context)['users'][logged_in]
    main = get_renderer('../templates/master.pt').implementation()
    activityLog = find_root(context)['activityLogs']
    user = context.user
    if not logged_in == context.user.username:
        if not (find_root(context)['users'][logged_in].isAdvisor or find_root(context)['users'][logged_in].isOfficer): 
            return {'red':'/serviceLogs/'+context.user.username+'/'+str(context.ID),
                    'main':main,
                    'form':"", 
                    'content':'Permission Denied',
                    'logged_in':logged_in,
                    'name':"Redirecting...",
		    'TutText': getTutText(user, view='')}
    if context.verified == "Verified":
        if not (find_root(context)['users'][logged_in].isAdvisor or find_root(context)['users'][logged_in].isOfficer): 
            return {'red':'/serviceLogs/'+context.user.username+'/'+str(context.ID),
                    'main':main,
                    'form':"", 
                    'content':'Permission Denied',
                    'logged_in':logged_in,
                    'name':"Redirecting...",
		    'TutText': getTutText(user, view='')}
    if context.eventType == "Independent":
        schema = IndependentEventEditSchema()
        eventform = Form(schema, buttons=('submit',))
        if 'description' in request.params:
            try:
                controls = request.POST.items()
                captured = eventform.validate(controls)
            except deform.ValidationFailure, e:
                eventform = e.render()
                return {'red':'',
                        'main':main, 
                        'form':eventform, 
                        'content':'',
                        'logged_in':logged_in,
                        'name':'Editing Independent Event',
			'TutText': getTutText(user, view='EditEvent')}
            context.completionDate = calendarstuff.datetime_from_str(request.params['completionDate'])
            context.eventType = request.params['eventType']
            if context.hours != request.params['hours']:
                if context.verified == "Verified": 
                    deltahours = float(request.params['hours'])-float(context.hours)
                    user.hours += deltahours   
            context.hours = request.params['hours']
            context.description = request.params['description']
            context.taskDescription = request.params['taskDescription']
            context.contact = request.params['contact']
            context.contactInfo = request.params['contactInfo']
            activityLog.event_edit(find_root(request.context)["users"][logged_in],context,request.application_url)
            return {'red':'serviceLogs/'+context.user.username,
                    'main':main,
                    'form':'',
                    'content':'Edited the event for '+context.description,
                    'logged_in':logged_in,
                    'name':'Redirecting...',
		    'TutText': getTutText(user, view='')}
        appstruct={'completionDate':context.completionDate,
                   'hours':context.hours,
                   'description':context.description,
                   'taskDescription':context.taskDescription,
                   'contact':context.contact,
                   'contactInfo':context.contactInfo,
                   'eventType':context.eventType,
		   'TutText': getTutText(user, view='')}
        eventform = eventform.render(appstruct=appstruct)
        return {'red':'',
                'main':main, 
                'form':eventform, 
                'content':'',
                'logged_in':logged_in,
                'name':'Editing Independent Event',
		'TutText': getTutText(user, view='')}
Beispiel #7
0
        schema=SponsoredEventSchema()
        eventform = Form(schema, buttons=('submit',))
        if 'taskDescription' in request.params:
            try:
                controls = request.POST.items()
                captured = eventform.validate(controls)
            except deform.ValidationFailure, e:
                eventform = e.render()
                return {'red':'',
                        'main':main, 
                        'form':eventform, 
                        'content':'',
                        'logged_in':logged_in,
                        'name':'Attempting to Edit Event',
			'TutText': getTutText(user, view='')}
            context.completionDate = calendarstuff.datetime_from_str(request.params['completionDate'])
            if context.hours != request.params['hours']:
                if context.verified == "Verified": 
                    deltahours = float(request.params['hours'])-float(context.hours)
                    user.hours += deltahours    
            context.hours = request.params['hours']
            #context.description = request.params['description']
            context.taskDescription = request.params['taskDescription']
            context.contact = request.params['contact']
            context.contactInfo = request.params['contactInfo']
            activitylog = find_root(context)['activityLogs']
            activitylog.event_edit(find_root(request.context)["users"][logged_in],context,request.application_url)
            return {'red':'serviceLogs/'+context.user.username,
                    'main':main,
                    'form':'',
                    'content':'Edited the event for '+context.description,
Beispiel #8
0
def add_sponsored_event(context, request):
    logged_in = authenticated_userid(request)
    main = get_renderer("../templates/master.pt").implementation()
    projectList = find_root(context)["settings"].projects
    projectTupleList = []
    for project in projectList:
        projectTupleList.append((project, project))
    projectTupleTuple = tuple(projectTupleList)  # sorry about this.  It was more fun than a ListList

    class SponsoredEventSchema(colander.MappingSchema):
        completionDate = colander.SchemaNode(colander.Date(), title="Completion Date (YYYY-MM-DD): ")
        hours = colander.SchemaNode(colander.Float(), title="Number of Hours: ")
        description = colander.SchemaNode(
            colander.String(),
            validator=colander.OneOf([x[0] for x in projectTupleTuple]),
            widget=deform.widget.RadioChoiceWidget(values=projectTupleTuple),
            title="Project",
            description="Select a Project",
        )
        taskDescription = colander.SchemaNode(
            colander.String(),
            title="Description: ",
            widget=deform.widget.TextAreaWidget(rows=5, cols=40),
            description="Enter some text",
        )
        contact = colander.SchemaNode(colander.String(), title="Contact Name: ")
        contactInfo = colander.SchemaNode(colander.String(), title="Contact Info: ")

    schema = SponsoredEventSchema()
    eventform = Form(schema, buttons=("submit",))
    if "taskDescription" in request.params:
        try:
            controls = request.POST.items()
            captured = eventform.validate(controls)
        except deform.ValidationFailure, e:
            eventform = e.render()
            return {
                "red": "",
                "main": main,
                "form": eventform,
                "content": "",
                "logged_in": logged_in,
                "name": "Add Sponsored Event",
            }
        completionDate = calendarstuff.datetime_from_str(request.params["completionDate"])
        hours = request.params["hours"]
        description = request.params["deformField3"]
        taskDescription = request.params["taskDescription"]
        contact = request.params["contact"]
        contactInfo = request.params["contactInfo"]
        context.eventcount += 1
        user = context.user
        event = Event(
            "Sponsored",
            completionDate,
            hours,
            description,
            taskDescription,
            contact,
            contactInfo,
            user,
            context.eventcount,
        )
        event.__parent__ = context
        context[str(context.eventcount)] = event
        activitylog = find_root(context)["activityLogs"]
        activitylog.event_creation(find_root(request.context)["users"][logged_in], event, request.application_url)
        return {
            "red": "serviceLogs/" + context.user.username,
            "main": main,
            "form": "",
            "content": "Added sponsored event for " + description,
            "logged_in": logged_in,
            "name": "Redirecting...",
        }
Beispiel #9
0
def edit_event(context, request):
    logged_in = authenticated_userid(request)
    main = get_renderer("../templates/master.pt").implementation()
    activityLog = find_root(context)["activityLogs"]
    user = context.user
    if not logged_in == context.user.username:
        if not (find_root(context)["users"][logged_in].isAdvisor or find_root(context)["users"][logged_in].isOfficer):
            return {
                "red": "/serviceLogs/" + context.user.username + "/" + str(context.ID),
                "main": main,
                "form": "",
                "content": "Permission Denied",
                "logged_in": logged_in,
                "name": "Redirecting...",
            }
    if context.verified == "Verified":
        if not (find_root(context)["users"][logged_in].isAdvisor or find_root(context)["users"][logged_in].isOfficer):
            return {
                "red": "/serviceLogs/" + context.user.username + "/" + str(context.ID),
                "main": main,
                "form": "",
                "content": "Permission Denied",
                "logged_in": logged_in,
                "name": "Redirecting...",
            }
    if context.eventType == "Independent":
        schema = IndependentEventEditSchema()
        eventform = Form(schema, buttons=("submit",))
        if "description" in request.params:
            try:
                controls = request.POST.items()
                captured = eventform.validate(controls)
            except deform.ValidationFailure, e:
                eventform = e.render()
                return {
                    "red": "",
                    "main": main,
                    "form": eventform,
                    "content": "",
                    "logged_in": logged_in,
                    "name": "Editing Independent Event",
                }
            context.completionDate = calendarstuff.datetime_from_str(request.params["completionDate"])
            context.eventType = request.params["eventType"]
            if context.hours != request.params["hours"]:
                if context.verified == "Verified":
                    deltahours = float(request.params["hours"]) - float(context.hours)
                    user.hours += deltahours
            context.hours = request.params["hours"]
            context.description = request.params["description"]
            context.taskDescription = request.params["taskDescription"]
            context.contact = request.params["contact"]
            context.contactInfo = request.params["contactInfo"]
            activityLog.event_edit(find_root(request.context)["users"][logged_in], context, request.application_url)
            return {
                "red": "serviceLogs/" + context.user.username,
                "main": main,
                "form": "",
                "content": "Edited the event for " + context.description,
                "logged_in": logged_in,
                "name": "Redirecting...",
            }
        appstruct = {
            "completionDate": context.completionDate,
            "hours": context.hours,
            "description": context.description,
            "taskDescription": context.taskDescription,
            "contact": context.contact,
            "contactInfo": context.contactInfo,
            "eventType": context.eventType,
        }
        eventform = eventform.render(appstruct=appstruct)
        return {
            "red": "",
            "main": main,
            "form": eventform,
            "content": "",
            "logged_in": logged_in,
            "name": "Editing Independent Event",
        }