Example #1
0
 def teacherhandout(self,
                    request,
                    tl,
                    one,
                    two,
                    module,
                    extra,
                    prog,
                    template_file='teacherschedules.html'):
     #   Use the template defined in ProgramPrintables
     from esp.program.modules.handlers import ProgramPrintables
     context = {'module': self}
     pmos = ProgramModuleObj.objects.filter(
         program=prog, module__handler__icontains='printables')
     if pmos.count() == 1:
         pmo = ProgramPrintables(pmos[0])
         teacher = ESPUser(request.user)
         scheditems = []
         for cls in teacher.getTaughtClasses().filter(
                 parent_program=self.program):
             if cls.isAccepted():
                 for section in cls.sections.all():
                     scheditems.append({
                         'name': teacher.name(),
                         'teacher': teacher,
                         'cls': section
                     })
         scheditems.sort()
         context['scheditems'] = scheditems
         return render_to_response(pmo.baseDir() + template_file, request,
                                   context)
     else:
         raise ESPError(
             False
         ), 'No printables module resolved, so this document cannot be generated.  Consult the webmasters.'
Example #2
0
 def volunteerschedule(self, request, tl, one, two, module, extra, prog):
     #   Use the template defined in ProgramPrintables
     from esp.program.modules.handlers import ProgramPrintables
     context = {'module': self}
     pmos = ProgramModuleObj.objects.filter(
         program=prog, module__handler__icontains='printables')
     if pmos.count() == 1:
         pmo = ProgramPrintables(pmos[0])
         if request.user.isAdmin() and 'user' in request.GET:
             volunteer = ESPUser.objects.get(id=request.GET['user'])
         else:
             volunteer = request.user
         scheditems = []
         offers = VolunteerOffer.objects.filter(
             user=volunteer, request__program=self.program)
         for offer in offers:
             scheditems.append({
                 'name': volunteer.name(),
                 'volunteer': volunteer,
                 'offer': offer
             })
         #sort the offers by timeslot
         scheditems.sort(
             key=lambda item: item['offer'].request.timeslot.start)
         context['scheditems'] = scheditems
         return render_to_response(pmo.baseDir() + 'volunteerschedule.html',
                                   request, context)
     else:
         raise ESPError(
             'No printables module resolved, so this document cannot be generated.  Consult the webmasters.',
             log=False)
 def teacherhandout(self, request, tl, one, two, module, extra, prog, template_file='teacherschedules.html'):
     #   Use the template defined in ProgramPrintables
     from esp.program.modules.handlers import ProgramPrintables
     context = {'module': self}
     pmos = ProgramModuleObj.objects.filter(program=prog,module__handler__icontains='printables')
     if pmos.count() == 1:
         pmo = ProgramPrintables(pmos[0])
         if request.user.isAdmin() and 'user' in request.GET:
             teacher = ESPUser.objects.get(id=request.GET['user'])
         else:
             teacher = request.user
         scheditems = []
         for cls in teacher.getTaughtClasses().filter(parent_program = self.program):
             if cls.isAccepted():
                 for section in cls.sections.all():
                     scheditems.append({'name': teacher.name(), 'teacher': teacher, 'cls': section})
         scheditems.sort()
         context['scheditems'] = scheditems
         return render_to_response(pmo.baseDir()+template_file, request, context)
     else:
         raise ESPError('No printables module resolved, so this document cannot be generated.  Consult the webmasters.', log=False)