예제 #1
0
    def createBit(self, extension):
        verb = GetNode('V/Flags/Registration/' + extension)
        ub = UserBit.objects.filter(user=self.student,
                                    verb=verb,
                                    qsc=self.program_anchor_cached())
        if len(ub) > 0:
            return False

        ub = UserBit()
        ub.verb = verb
        ub.qsc = self.program_anchor_cached()
        ub.user = self.student
        ub.recursive = False
        ub.save()
        return True
예제 #2
0
 def gen_userbit(tup):
     new_ub = UserBit()
     new_ub.verb = DataTree.get_by_uri(tup[0], create=True)
     new_ub.qsc = prog.anchor
     new_ub.recursive = True
     if tup[2]:
         new_ub.startdate = tup[2]
     if tup[3]:
         new_ub.enddate = tup[3]
     if (tup[1] is None) or (tup[1] == 0):
         new_ub.user = None
     elif type(tup[1]) in (User, ESPUser):
         new_ub.user = tup[1]
     else:
         new_ub.user = ESPUser.objects.get(id=tup[1])        
     new_ub.save()
     return new_ub
예제 #3
0
    def satprep_create(self, request, tl, one, two, module, extra, prog):
        if request.method == 'POST':
            form = OnSiteSATPrepRegForm(request.POST)

            if form.is_valid():
                new_data = form.cleaned_data
                username = base_uname = (new_data['first_name'][0]+ \
                                         new_data['last_name']).lower()
                if ESPUser.objects.filter(username=username).count() > 0:
                    i = 2
                    username = base_uname + str(i)
                    while ESPUser.objects.filter(
                            username=username).count() > 0:
                        i += 1
                        username = base_uname + str(i)
                new_user = ESPUser(username=username,
                                   first_name=new_data['first_name'],
                                   last_name=new_data['last_name'],
                                   email=new_data['email'],
                                   is_staff=False,
                                   is_superuser=False)
                new_user.save()
                self.student = new_user
                new_user.recoverPassword()

                #update satprep information
                satprep = SATPrepRegInfo.getLastForProgram(
                    new_user, self.program)
                satprep.old_math_score = new_data['old_math_score']
                satprep.old_verb_score = new_data['old_verb_score']
                satprep.old_writ_score = new_data['old_writ_score']
                satprep.save()

                if new_data['paid']:
                    self.createBit('Paid')

                self.createBit('Attended')

                if new_data['medical']:
                    self.createBit('MedicalFiled')

                if new_data['liability']:
                    self.createBit('LiabilityFiled')

                self.createBit('OnSite')

                v = GetNode('V/Flags/UserRole/Student')
                ub = UserBit()
                ub.user = new_user
                ub.recursive = False
                ub.qsc = GetNode('Q')
                ub.verb = v
                ub.save()

                new_user = ESPUser(new_user)

                return render_to_response(self.baseDir() + 'reg_success.html',
                                          request, (prog, tl),
                                          {'user': new_user})

        else:
            form = OnSiteSATPrepRegForm()

        return render_to_response(self.baseDir() + 'reg_info.html', request,
                                  (prog, tl), {'form': form})
예제 #4
0
    def onsite_create(self, request, tl, one, two, module, extra, prog):
        if request.method == 'POST':
            form = OnSiteRegForm(request.POST)
            
            if form.is_valid():
                new_data = form.cleaned_data
                username = ESPUser.get_unused_username(new_data['first_name'], new_data['last_name'])
                new_user = ESPUser(username = username,
                                first_name = new_data['first_name'],
                                last_name  = new_data['last_name'],
                                email      = new_data['email'],
                                is_staff   = False,
                                is_superuser = False)
                new_user.save()

                self.student = new_user

                regProf = RegistrationProfile.getLastForProgram(new_user,
                                                                self.program)
                contact_user = ContactInfo(first_name = new_user.first_name,
                                           last_name  = new_user.last_name,
                                           e_mail     = new_user.email,
                                           user       = new_user)
                contact_user.save()
                regProf.contact_user = contact_user

                student_info = StudentInfo(user = new_user, graduation_year = ESPUser.YOGFromGrade(new_data['grade']))
                student_info.save()
                regProf.student_info = student_info

                regProf.save()
                
                if new_data['paid']:
                    self.createBit('Paid')
                    self.updatePaid(True)
                else:
                    self.updatePaid(False)

                self.createBit('Attended')

                if new_data['medical']:
                    self.createBit('MedicalFiled')

                if new_data['liability']:
                    self.createBit('LiabilityFiled')

                self.createBit('OnSite')

                v = GetNode( 'V/Flags/UserRole/Student')
                ub = UserBit()
                ub.user = new_user
                ub.recursive = False
                ub.qsc = GetNode('Q')
                ub.verb = v
                ub.save()

                new_user.recoverPassword()
                
                return render_to_response(self.baseDir()+'reg_success.html', request, (prog, tl), {
                    'student': new_user, 
                    'retUrl': '/onsite/%s/classchange_grid?student_id=%s' % (self.program.getUrlBase(), new_user.id)
                    })

        else:
            form = OnSiteRegForm()

	return render_to_response(self.baseDir()+'reg_info.html', request, (prog, tl), {'form':form, 'current_year':ESPUser.current_schoolyear()})