Beispiel #1
0
 def post(self, request, **kwargs):
     if 'title' in request.POST and request.POST['title']:
         title=request.POST['title'].strip()
         #如果有id,则修改
         if 'id' in request.POST and request.POST['id']:
             reservationid=request.POST['id']
             try:
                 reservation=Reservation.objects.get(id=reservationid)
             except Reservation.DoesNotExist:
                 return Util.GetResponseData(False,810)
             reservation.title = title
             reservation.modifytime = time.time()
         else:
             #新建
             reservation=Reservation.objects.create(title=title)
         if 'student' in request.POST:
             reservation.student= request.POST['student'].strip()
         if 'name' in request.POST:
             reservation.name = request.POST['name'].strip()
         if 'role' in request.POST:
             reservation.role = request.POST['role'].strip()
         if 'reserve_date' in request.POST:
             reservation.reserve_date = request.POST['reserve_date'].strip()
         if 'address' in request.POST:
             reservation.address = request.POST['address'].strip()
         if 'remark' in request.POST:
             reservation.remark = request.POST['remark'].strip()
         if 'reserve_others' in request.POST:
             reservation.reserve_others = request.POST['reserve_others'].strip()
         if 'phone' in request.POST:
             reservation.phone = request.POST['phone'].strip()
         reservation.save()
         return Util.GetResponseData(True,0,reservation.id)
     else:
         return Util.GetResponseData(False,-3)
Beispiel #2
0
 def post(self, request, **kwargs):
     if 'classname' in request.POST and request.POST['classname']:
         classname = request.POST['classname'].strip()
         #如果有id,则修改
         if 'id' in request.POST and request.POST['id']:
             classid = request.POST['id']
             try:
                 classinfo = ClassInfo.objects.get(id=classid)
             except ClassInfo.DoesNotExist:
                 return Util.GetResponseData(False, 610)
             classinfo.classname = classname
             classinfo.modifytime = time.time()
         else:
             #新建
             classinfo = ClassInfo.objects.create(classname=classname)
         if 'description' in request.POST:
             classinfo.description = request.POST['description'].strip()
         if 'container' in request.POST:
             classinfo.container = request.POST['container'].strip()
         if 'headteacher' in request.POST:
             classinfo.headteacher = request.POST['headteacher'].strip()
         if 'headteacher_phone' in request.POST:
             classinfo.headteacher_phone = request.POST[
                 'headteacher_phone'].strip()
         if 'monitor' in request.POST:
             classinfo.monitor = request.POST['monitor'].strip()
         classinfo.save()
         return Util.GetResponseData(True, 0, classinfo.id)
     else:
         return Util.GetResponseData(False, -3)
    def post(self, request, **kwargs):
        if 'title' in request.POST and request.POST['title']:
            title = request.POST['title'].strip()
            #如果有id,则修改
            if 'id' in request.POST and request.POST['id']:
                newid = request.POST['id']
                try:
                    education = EducationCare.objects.get(id=newid)
                except EducationCare.DoesNotExist:
                    return Util.GetResponseData(False, 710)
                education.title = title
                education.modifytime = time.time()
            else:
                #新建
                education = EducationCare.objects.create(
                    title=title, userid=request.user.id)
            if 'author' in request.POST:
                education.author = request.POST['author'].strip()
            if 'description' in request.POST:
                education.description = request.POST['description'].strip()
            if 'source' in request.POST:
                education.source = request.POST['source'].strip()
            if 'video' in request.POST:
                education.video = request.POST['video'].strip()
            #视频
            if 'fileid' in request.POST and request.POST['fileid']:
                fileid = request.POST['fileid'].strip()
                if fileid in request.session and request.session[fileid]:
                    fileinfo = request.session[fileid]
                    education.video = fileinfo["filepath"]

            education.save()
            return Util.GetResponseData(True, 0, education.id)
        else:
            return Util.GetResponseData(False, -3)
Beispiel #4
0
 def post(self, request, **kwargs):
     if 'classid' in kwargs and kwargs[
             'classid'] and 'teacherid' in request.POST and request.POST[
                 'teacherid']:
         classid = kwargs['classid']
         teacherid = request.POST['teacherid']
         try:
             classinfo = ClassInfo.objects.get(id=classid)
             teacher = TeacherInfo.objects.get(id=teacherid)
         except ClassInfo.DoesNotExist or TeacherInfo.DoesNotExist:
             return Util.GetResponseData(False, 610)
         #如果有id,则修改
         if 'id' in request.POST and request.POST['id']:
             ctid = request.POST['id']
             try:
                 class_teacher = ClassTeachers.objects.get(id=ctid)
                 class_teacher.classinfo = classinfo
             except ClassTeachers.DoesNotExist:
                 class_teacher = ClassTeachers.objects.create(
                     teacher=teacher, classinfo=classinfo)
         else:
             class_teacher = ClassTeachers.objects.create(
                 teacher=teacher, classinfo=classinfo)
         if 'role' in request.POST and request.POST['role']:
             class_teacher.role = request.POST['role']
         class_teacher.save()
         return Util.GetResponseData(True, 0, class_teacher.id)
     return Util.GetResponseData(False, -3)
 def post(self, request, **kwargs):
     if 'file' in request.FILES and "activityid" in kwargs and kwargs[
             "activityid"]:
         filedata = request.FILES["file"]
         activityid = kwargs["activityid"]
         if filedata:
             #是否使用云存储
             if settings.USE_STORAGE:
                 filename, filepath, filesize, guid = Util.profile_upload_storage(
                     filedata, "/activity")
             else:
                 filename, filepath, filesize, guid = Util.profile_upload(
                     filedata, "/activity")
             try:
                 activity = ActivityInfo.objects.get(id=activityid)
             except ActivityInfo.DoesNotExist:
                 return Util.GetResponseData(False, 310)
             userid = request.user.id
             #是否是封面,默认第一张
             is_face = True
             if activity.activeImage:
                 is_face = False
             photo = ActivityPhoto.objects.create(activity=activity,
                                                  title=filename,
                                                  filepath=filepath,
                                                  userid=userid,
                                                  is_face=is_face)
             #photo.save()
             return Util.GetResponseData(True, 0, photo.id)
     return Util.GetResponseData(False, -3)
Beispiel #6
0
 def post(self, request, **kwargs):
     if 'classid' in kwargs and kwargs[
             'classid'] and 'studentid' in request.POST and request.POST[
                 'studentid']:
         classid = kwargs['classid']
         studentid = request.POST['studentid']
         try:
             classinfo = ClassInfo.objects.get(id=classid)
             student = StudentInfo.objects.get(id=studentid)
         except ClassInfo.DoesNotExist or StudentInfo.DoesNotExist:
             return Util.GetResponseData(False, 610)
         #如果有id,则修改
         if 'id' in request.POST and request.POST['id']:
             csid = request.POST['id']
             try:
                 class_student = ClassStudents.objects.get(id=csid)
                 class_student.classinfo = classinfo
             except ClassInfo.DoesNotExist:
                 class_student = ClassStudents.objects.create(
                     student=student, classinfo=classinfo)
         else:
             class_student = ClassStudents.objects.create(
                 student=student, classinfo=classinfo)
         if 'year' in request.POST and request.POST['year']:
             class_student.year = request.POST['year']
         if 'joindate' in request.POST and request.POST['joindate']:
             class_student.joindate = request.POST['joindate']
         if 'role' in request.POST and request.POST['role']:
             class_student.role = request.POST['role']
         class_student.save()
         return Util.GetResponseData(True, 0, class_student.id)
     return Util.GetResponseData(False, -3)
Beispiel #7
0
 def post(self, request, **kwargs):
     if 'title' in request.POST and request.POST['title']:
         title=request.POST['title'].strip()
         #如果有id,则修改
         if 'id' in request.POST and request.POST['id']:
             newid=request.POST['id']
             try:
                 news=NewsInfo.objects.get(id=newid)
             except NewsInfo.DoesNotExist:
                 return Util.GetResponseData(False,210)
             news.title = title
             news.modifytime = time.time()
         else:
             #新建
             news=NewsInfo.objects.create(title=title)
         if 'author' in request.POST:
             news.author= request.POST['author'].strip()
         if 'content' in request.POST:
             news.content = request.POST['content'].strip()
         if 'news_type' in request.POST:
             news.news_type = request.POST['news_type'].strip()
         news.save()
         return Util.GetResponseData(True,0,news.id)
     else:
         return Util.GetResponseData(False,-3)
 def post(self, request, *args, **kwargs):
     if 'fileid' in kwargs and kwargs['fileid'] != "":
         fileid = kwargs['fileid']
         if fileid in request.session and request.session[fileid]:
             fileinfo = request.session[fileid]
             filepath = fileinfo['filepath']
             Util.profile_delete(filepath)
         return Util.GetResponseData(True)
     return Util.GetResponseData(False, -3)
Beispiel #9
0
 def post(self, request, **kwargs):
     if 'reservationid' in kwargs and kwargs['reservationid']:
         reservationid = kwargs['reservationid']
         try:
             reservation = Reservation.objects.get(id=reservationid)
         except Reservation.DoesNotExist:
             return Util.GetResponseData(False,810)
         reservation.read()
         return Util.GetResponseData(True)
     return Util.GetResponseData(False,-3)
Beispiel #10
0
 def get(self, request, **kwargs):
     if 'reservationid' in kwargs and kwargs['reservationid']:
         reservationid = kwargs['reservationid']
         try:
             reservation = Reservation.objects.get(id=reservationid)
         except Reservation.DoesNotExist:
             return Util.GetResponseData(False,810)
         data=ReservationSerializer(reservation).data
         return Util.GetResponseData(True,0,data,1)
     return Util.GetResponseData(False,-3)
Beispiel #11
0
 def get(self, request, **kwargs):
     if 'userid' in kwargs and kwargs['userid']:
         userid = kwargs['userid']
         try:
             user = User.objects.get(id=userid)
         except User.DoesNotExist:
             return Util.GetResponseData(False, 110)
         profile = UserInfoSerializer(user).data
         return Util.GetResponseData(True, 0, profile)
     return Util.GetResponseData(False, -3)
Beispiel #12
0
 def get(self, request, **kwargs):
     if 'id' in kwargs and kwargs['id']:
         csid = kwargs['id']
         try:
             class_student = ClassStudents.objects.get(id=csid)
         except ClassInfo.DoesNotExist:
             return Util.GetResponseData(False, 610)
         data = ClassStudentSerializer(class_student).data
         return Util.GetResponseData(True, 0, data, 1)
     return Util.GetResponseData(False, -3)
Beispiel #13
0
 def post(self, request, **kwargs):
     if 'id' in kwargs and kwargs['id']:
         photoid = kwargs['id']
         try:
             photo = ActivityPhoto.objects.get(id=photoid)
         except ActivityPhoto.DoesNotExist:
             return Util.GetResponseData(False, 910)
         photo.delete()
         return Util.GetResponseData(True)
     return Util.GetResponseData(False, -3)
Beispiel #14
0
 def post(self, request, **kwargs):
     if 'id' in kwargs and kwargs['id']:
         classid = kwargs['id']
         try:
             info = ClassTeachers.objects.get(id=classid)
         except ClassTeachers.DoesNotExist:
             return Util.GetResponseData(False, 410)
         info.delete()
         return Util.GetResponseData(True, 0)
     else:
         return Util.GetResponseData(False, -3)
Beispiel #15
0
 def get(self, request, **kwargs):
     if 'teacherid' in kwargs and kwargs['teacherid']:
         teacherid = kwargs['teacherid']
         try:
             teacher = TeacherInfo.objects.get(id=teacherid)
         except TeacherInfo.DoesNotExist:
             return Util.GetResponseData(False, 410)
         datalist = func.GetClassByTeacher(teacher)
         data = ClassInfoSerializer(datalist).data
         return Util.GetResponseData(True, 0, data, 1)
     return Util.GetResponseData(False, -3)
Beispiel #16
0
 def post(self, request, **kwargs):
     if 'educationid' in kwargs and kwargs['educationid']:
         educationid = kwargs['educationid']
         try:
             education = EducationCare.objects.get(id=educationid)
         except EducationCare.DoesNotExist:
             return Util.GetResponseData(False, 710)
         education.delete()
         return Util.GetResponseData(True, 0)
     else:
         return Util.GetResponseData(False, -3)
Beispiel #17
0
 def post(self, request, **kwargs):
     if 'courseid' in kwargs and kwargs['courseid']:
         courseid = kwargs['courseid']
         try:
             course = CourseInfo.objects.get(id=courseid)
         except CourseInfo.DoesNotExist:
             return Util.GetResponseData(False, 710)
         course.delete()
         return Util.GetResponseData(True, 0)
     else:
         return Util.GetResponseData(False, -3)
Beispiel #18
0
 def post(self, request, **kwargs):
     if 'teacherid' in kwargs and kwargs['teacherid']:
         teacherid=kwargs['teacherid']
         try:
             teacher=TeacherInfo.objects.get(id=teacherid)
         except TeacherInfo.DoesNotExist:
             return Util.GetResponseData(False,410)
         teacher.delete()
         return Util.GetResponseData(True)
     else:
         return Util.GetResponseData(False,-3)
Beispiel #19
0
 def post(self, request, **kwargs):
     if 'studentid' in kwargs and kwargs['studentid']:
         studentid=kwargs['studentid']
         try:
             student=StudentInfo.objects.get(id=studentid)
         except StudentInfo.DoesNotExist:
             return Util.GetResponseData(False,510)
         student.delete()
         return Util.GetResponseData(True)
     else:
         return Util.GetResponseData(False,-3)
Beispiel #20
0
 def post(self, request, **kwargs):
     if 'userid' in kwargs and kwargs['userid']:
         userid = kwargs['userid']
         try:
             user = User.objects.get(id=userid)
         except User.DoesNotExist:
             return Util.GetResponseData(False, 210)
         user.delete()
         return Util.GetResponseData(True)
     else:
         return Util.GetResponseData(False, -3)
Beispiel #21
0
 def post(self, request, **kwargs):
     if 'newsid' in kwargs and kwargs['newsid']:
         newsid=kwargs['newsid']
         try:
             news=NewsInfo.objects.get(id=newsid)
         except NewsInfo.DoesNotExist:
             return Util.GetResponseData(False,210)
         news.delete()
         return Util.GetResponseData(True)
     else:
         return Util.GetResponseData(False,-3)
Beispiel #22
0
 def get(self, request, **kwargs):
     if 'teacherid' in request.GET and request.GET['teacherid']:
         teacherid = request.GET['teacherid'].strip()
         args = {}
         try:
             teacher = TeacherInfo.objects.get(id=teacherid)
         except TeacherInfo.DoesNotExist:
             return func.GetClassList(**args)
         datalist = func.GetClassListUnJoinForTeacher(teacher, **args)
         data = ClassInfoSerializer(datalist).data
         return Util.GetResponseData(True, 0, data, datalist.count())
     return Util.GetResponseData(False, -3)
Beispiel #23
0
 def post(self, request, **kwargs):
     if 'activityid' in kwargs and kwargs['activityid']:
         activityid = kwargs['activityid']
         try:
             activity = ActivityInfo.objects.get(id=activityid)
         except ActivityInfo.DoesNotExist:
             return Util.GetResponseData(False, -3)
         #删除照片
         ActivityPhoto.objects.filter(activity=activity).delete()
         activity.delete()
         return Util.GetResponseData(True)
     return Util.GetResponseData(False, -3)
Beispiel #24
0
 def post(self, request, **kwargs):
     if 'studentid' in kwargs and kwargs['studentid']:
         studentid = kwargs['studentid']
         try:
             student = StudentInfo.objects.get(id=studentid)
         except StudentInfo.DoesNotExist:
             return Util.GetResponseData(False,510)
         istop=True
         if 'photo' in kwargs and kwargs['istop']:
             student.photo = kwargs['photo'].strip()
             student.save()
             return Util.GetResponseData(True)
     return Util.GetResponseData(False,-3)
Beispiel #25
0
 def post(self, request, **kwargs):
     if 'teacherid' in kwargs and kwargs['teacherid']:
         teacherid = kwargs['teacherid']
         try:
             teacher = TeacherInfo.objects.get(id=teacherid)
         except TeacherInfo.DoesNotExist:
             return Util.GetResponseData(False,410)
         istop=True
         if 'photo' in kwargs and kwargs['istop']:
             teacher.photo = kwargs['photo'].strip()
             teacher.save()
             return Util.GetResponseData(True)
     return Util.GetResponseData(False,-3)
Beispiel #26
0
 def post(self, request, **kwargs):
     if 'newsid' in kwargs and kwargs['newsid']:
         newsid = kwargs['newsid']
         try:
             news = NewsInfo.objects.get(id=newsid)
         except NewsInfo.DoesNotExist:
             return Util.GetResponseData(False,210)
         istop=True
         if 'istop' in request.POST and request.POST['istop'] and request.POST['istop']=='false':
             istop=False
         news.setTop(istop)
         return Util.GetResponseData(True)
     return Util.GetResponseData(False,-3)
Beispiel #27
0
 def post(self, request, *args, **kwargs):
     if 'userid' in kwargs and kwargs[
             'userid'] and 'password' in request.POST and request.POST[
                 'password']:
         userid = kwargs['userid']
         password = request.POST['password'].strip()
         try:
             user = User.objects.get(id=userid)
         except User.DoesNotExist:
             return Util.GetResponseData(False, 110)
         user.set_password(password)
         user.save()
         return Util.GetResponseData(True)
     return Util.GetResponseData(False, -3)
Beispiel #28
0
 def post(self, request, **kwargs):
     if 'userid' in kwargs and kwargs['userid']:
         userid = kwargs['userid']
         try:
             user = User.objects.get(id=userid)
         except User.DoesNotExist:
             return Util.GetResponseData(False, 110)
         if 'first_name' in request.POST and request.POST["first_name"]:
             user.first_name = request.POST['first_name'].strip()
         if 'email' in request.POST and request.POST["email"]:
             user.email = request.POST['email'].strip()
         user.save()
         return Util.GetResponseData(True, 0, user.id)
     else:
         return Util.GetResponseData(False, -3)
Beispiel #29
0
 def get(self, request, **kwargs):
     if 'classid' in kwargs and kwargs['classid']:
         classid = kwargs['classid']
         #分页
         pagesize, pageindex = Util.getPageSizeAndIndex(request)
         args = {}
         args["classinfo__id"] = classid
         #查询条件
         if 'name' in request.GET and request.GET['name']:
             args['teacher__name__contains'] = request.GET['name'].strip()
         datalist, counts = func.GetClassTeacherPageList(
             pagesize, pageindex, **args)
         data = ClassTeacherSerializer(datalist).data
         return Util.GetResponseData(True, 0, data, counts)
     return Util.GetResponseData(False, -3)
Beispiel #30
0
 def post(self, request, **kwargs):
     if 'content' in request.POST and request.POST[
             'content'] and 'courseid' in kwargs and kwargs['courseid']:
         content = Util.GetFilterString(request.POST['content'])
         courseid = kwargs['courseid']
         user = User()
         if request.user and request.user.is_authenticated():
             user = request.user
         #1:新闻,2:课程,3:活动
         comment = CommentInfo.objects.create(content=content,
                                              userid=user,
                                              mod=2,
                                              obj_id=courseid)
         return Util.GetResponseData(True, 0, comment.id)
     return Util.GetResponseData(False, -3)