예제 #1
0
 def test_IntakeInternalForm_valid(self):
     data = {
         "student_id": 1,
         "enrollment_date": "2017-01-01",
         "starting_grade": 1
     }
     form = IntakeInternalForm(data)
     self.assertTrue(form.is_valid())
예제 #2
0
파일: surveys.py 프로젝트: AsianHope/vdpme
def intake_internal(request, student_id=0):
    #get current method name
    method_name = inspect.currentframe().f_code.co_name
    if user_permissions(method_name, request.user):

        if request.method == 'POST':
            form = IntakeInternalForm(request.POST)
            if form.is_valid():
                instance = form.save()
                message = ('Enrolled  ' + unicode(instance.student_id.name) +
                           ' in ' + instance.get_starting_grade_display())
                log = NotificationLog(user=request.user,
                                      text=message,
                                      font_awesome_icon='fa-user-plus')
                log.save()
                #then return
                return HttpResponseRedirect(
                    reverse(
                        'student_detail',
                        kwargs={'student_id': instance.student_id.student_id}))
        else:
            if student_id > 0:
                form = IntakeInternalForm({'student_id': student_id})
            else:
                form = IntakeInternalForm()

        context = {
            'form': form,
        }
        return render(request, 'mande/intakeinternal.html', context)
    else:
        raise PermissionDenied
예제 #3
0
파일: surveys.py 프로젝트: suin-kim/vdpme
def intake_internal(request, student_id=0):

    if request.method == "POST":
        form = IntakeInternalForm(request.POST)
        if form.is_valid():
            instance = form.save()
            message = "Enrolled  " + unicode(instance.student_id.name) + " in " + instance.get_starting_grade_display()
            log = NotificationLog(user=request.user, text=message, font_awesome_icon="fa-user-plus")
            log.save()
            # then return
            return HttpResponseRedirect(
                reverse("student_detail", kwargs={"student_id": instance.student_id.student_id})
            )
    else:
        if student_id > 0:
            form = IntakeInternalForm({"student_id": student_id})
        else:
            form = IntakeInternalForm()

    context = {"form": form}
    return render(request, "mande/intakeinternal.html", context)
예제 #4
0
파일: surveys.py 프로젝트: rice1got/vdpme
def intake_internal(request, student_id=0):

    if request.method == 'POST':
        form = IntakeInternalForm(request.POST)
        if form.is_valid():
            instance = form.save()
            message = ( 'Enrolled  '+unicode(instance.student_id.name)+
                        ' in '+instance.get_starting_grade_display())
            log = NotificationLog(  user=request.user,
                                    text=message,
                                    font_awesome_icon='fa-user-plus')
            log.save()
            #then return
            return HttpResponseRedirect(reverse('student_detail',kwargs=
                                {'student_id':instance.student_id.student_id}))
    else:
        if student_id > 0:
            form = IntakeInternalForm({'student_id':student_id})
        else:
            form = IntakeInternalForm()

    context = {'form': form,}
    return render(request, 'mande/intakeinternal.html', context)
예제 #5
0
 def test_IntakeInternalForm_invalid(self):
     data = {"enrollment_date": "2017-01-01", "starting_grade": 1}
     form = IntakeInternalForm(data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
                      {'student_id': [u'This field is required.']})