Пример #1
0
    def post(self, request):
        """
        create clazz student

        :author: gexuewen
        :date: 2020/01/08
        """
        data = request.data.copy()
        student_id = data.get('student_id')
        clazz_id = data.get('clazz_id')
        recommendation_peoples = data.get('recommendation_people')
        clazz_student = ClazzStudent.objects.filter(clazz_id=clazz_id, student_id=student_id)
        if clazz_student.count() > 0:
            return result_util.error(ALREADY_APPLY, '已经参加过')
        self.evaluation = Evaluation.objects.create()
        apply_data = data.get('application')
        self.apply = ApplicationInformation.objects.create(**apply_data)
        if recommendation_peoples:
            for recommendation_people in recommendation_peoples:
                RecommendationPeople.objects.create(information=self.apply, **recommendation_people)
        self.student = Student.objects.filter(id=student_id).first()
        self.clazz = Clazz.objects.filter(id=clazz_id).first()
        data.update({'state': WAIT_FOR_AUDIT})
        clazz_student_serializer = self.get_serializer(data=data)
        clazz_student_serializer.is_valid(raise_exception=True)
        clazz_student_serializer.save()
        self.clazz.current_people_number = self.clazz.current_people_number + 1
        self.clazz.save()
        return result_util.success_empty()
Пример #2
0
    def delete(self, request, primary_key):
        """
        cancel activity

        :author: gexuewen
        :date: 2020/01/02
        """
        self.destroy(request, primary_key)
        return result_util.success_empty()
Пример #3
0
    def delete(self, request, primary_key):
        """
        delete administrator

        :author: lishanZheng
        :date: 2020/01/06
        """
        self.destroy(request, primary_key)
        return result_util.success_empty()
Пример #4
0
    def delete(self, request, primary_key):
        """
        delete content

        :author: lishanZheng
        :date: 2020/01/04
        """
        over = self.destroy(request, primary_key)
        if over is None:
            pass
        return result_util.success_empty()
Пример #5
0
def logout(request):
    """
    logout

    :author: lishanZheng
    :date: 2019/12/31
    """
    if request.session.get('is_login'):
        request.session['is_login'] = None
        request.session['admin'] = None
        return result_util.success_empty()
    return result_util.error(error_code=code.NOT_LOGIN, message='未登录')
Пример #6
0
    def delete(self, request, activity_id, param):
        """
        delete activity clazz

        :author: gexuewen
        :date: 2020/01/10
        """
        if param == 'all':
            activity_clazz_list = ActivityClazz.objects.filter(
                activity_id=activity_id)
            for activity_clazz in activity_clazz_list:
                activity_clazz.delete()
            return result_util.success_empty()
        activity_clazzes = ActivityClazz.objects.filter(
            activity_id=activity_id, clazz_id=int(param))
        instance = activity_clazzes.first()
        if instance:
            instance.delete()
        if not self:
            pass
        return result_util.success_empty()
Пример #7
0
 def perform_destroy(self, instance):
     instance.state = 0
     instance.save()
     return result_util.success_empty()