예제 #1
0
 def save(self):
     try:
         check_others = sess.query(other_publication).filter(other_publication.lecturer_nip == self.lecturer_nip). \
             filter(other_publication.title == self.title).first()
         if check_others is None:
             sess.add(self)
             sess.commit()
             new_other_publication = {
                 'id': self.id,
                 'lecturer_nip': self.lecturer_nip,
                 'title': self.title,
                 'year': self.year,
                 'publisher': self.publisher,
                 'filepath': self.filepath
             }
             ret = {
                 'status': 200,
                 'message': 'New Publication Registered',
                 'results': new_other_publication
             }
         else:
             ret = {
                 'status':
                 200,
                 'message':
                 'Your publication already registered before, please try again another publication!'
             }
         return ret
     except Exception as e:
         sess.rollback()
         ret = {'status': 200, 'message': e.args}
         return ret
     finally:
         sess.close()
예제 #2
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         check_achievement = sess.query(achievement).filter(achievement.lecturer_nip == self.lecturer_nip).filter(achievement.title==self.title).\
             filter(achievement.year == self.year).first()
         if check_achievement is None:
             sess.add(self)
             sess.commit()
             new_achievement = {
                 'id': self.id,
                 'lecturer_nip': self.lecturer_nip,
                 'title': self.title,
                 'issuer': self.issuer,
                 'year': self.year,
                 'filepath': self.filepath
             }
             ret = {
                 'status': 200,
                 'message': 'New Achievement Registered',
                 'results': new_achievement
             }
         else:
             ret = {
                 'status': 200,
                 'message': 'Your achievement already registered before, please try again another achievement!'
             }
         return ret
     except Exception as e:
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
             sess.close()
예제 #3
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         check_user = sess.query(lecturer).filter(lecturer.nip == self.nip).first()
         if check_user is not None:
             ret = {
                 'status': 200,
                 'message': "NIP already registered, try again another NIP"
             }
             return ret
         new_lecturer = {
             'name': self.name,
             'role': self.role,
             'nip': self.nip,
             'email': self.email
         }
         ret = {
             'status': 200,
             'message': 'Lecturer Registered',
             'results': new_lecturer
         }
         sess.add(self)
         sess.commit()
         return ret
     except Exception as e:
         sess.rollback()
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
             sess.close()
예제 #4
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         check_user = sess.query(admin).filter(admin.auth_id == self.auth_id).first()
         if check_user is not None:
             ret = {
                 'status': 200,
                 'message': "Auth_ID already registered, try again another Auth_ID"
             }
             return ret
         sess.add(self)
         sess.commit()
         new_admin = {
             'id': self.id,
             'auth_id': self.auth_id,
             'name': self.name,
             'role': self.role,
             'email': self.email
         }
         ret = {
             'status': 200,
             'message': 'Admin Registered',
             'results': new_admin
         }
         return ret
     except Exception as e:
         sess.rollback()
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
             sess.close()
예제 #5
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         sess.add(self)
         sess.commit()
         new_final_task_lecturer = {
             'id': self.id,
             'final_task_id': self.final_task_id,
             'lecturer_nip': self.lecturer_nip,
             'lecturer_position': self.lecturer_position,
         }
         ret = {
             'status': 200,
             'message': 'New Final Task Lecturer Registered',
             'results': "Sukses"
         }
         return ret
     except Exception as e:
         sess.rollback()
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
         sess.close()
예제 #6
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         sess.add(self)
         sess.commit()
         new_final_task = {
             'id': self.id,
             'student_name': self.student_name,
             'student_nim': self.student_nim,
             'student_type': self.student_type,
             'title': self.title,
             'starting_date': self.starting_date,
             'graduation_date': self.graduation_date
         }
         ret = {
             'status': 200,
             'message': 'New Final Task Registered',
             'results': new_final_task
         }
         return ret
     except Exception as e:
         sess.rollback()
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
         sess.close()
예제 #7
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         check_course = sess.query(academic).filter(
             academic.course_id == self.course_id).first()
         if check_course is not None:
             ret = {
                 'status':
                 200,
                 'message':
                 "Course already registered, try again another Course"
             }
             return ret
         sess.add(self)
         sess.commit()
         new_course = {
             'id': self.id,
             'course_id': self.course_id,
             'course_name': self.course_name,
             'total_classes': self.total_classes
         }
         ret = {
             'status': 200,
             'message': 'Course Registered',
             'results': new_course
         }
         return ret
     except Exception as e:
         sess.rollback()
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
         sess.close()
예제 #8
0
    def save(self):
        global saveJourCorr
        try:
            check_journal = sess.query(journal).filter(journal.lecturer_nip == self.lecturer_nip). \
                filter(journal.title == self.title).first()
            if check_journal is None:
                sess.add(self)
                sess.commit()
                new_journal = {
                    'lecturer_nip': self.lecturer_nip,
                    'title': self.title,
                    'issue': self.issue,
                    'year': self.year,
                    'number': self.number,
                    'total_page': self.total_page,
                    'type': self.type,
                    'doi': self.doi,
                    'link': self.link,
                    'filepath': self.filepath,
                    'names': self.names
                }

                # savejourCorr = True
                # for name in self.names:
                #     if saveJourCorr:
                #         saveJourCorr = journalCorrespondingAuthor(journal_id=self.id, names=name).save()
                #     else:
                #         return {'status': 200,
                #                 'message': 'something went wrong when we try to save corresponding author!'}
                if self.names:
                    names = self.names.split(",")
                    for name in names:
                        journalCorrespondingAuthor(journal_id=self.id,
                                                   names=name).save()
                # else:
                #     return {'status': 200, 'message': 'no corresponding author'}

                ret = {
                    'status': 200,
                    'message': 'New Journal Registered',
                    'results': new_journal
                }
            else:
                ret = {
                    'status':
                    200,
                    'message':
                    'Your journal already registered before, please try again another journal!'
                }
            return ret
        except Exception as e:
            sess.rollback()
            ret = {'status': 200, 'message': e.args}
            return ret
        finally:
            sess.close()
예제 #9
0
 def save(self):
     try:
         sess.add(self)
         sess.commit()
         return True
     except Exception as e:
         sess.rollback()
         return e
     finally:
         sess.close()
예제 #10
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         check_course = sess.query(academic).filter(
             academic.course_id == self.course_id).first()
         if check_course is None:
             ret = {
                 'status':
                 200,
                 'message':
                 "Course is not registered yet, try again another Course"
             }
             return ret
         check_lecturer = sess.query(academic_lecturer).filter(
             academic_lecturer.course_id == self.course_id,
             academic_lecturer.lecturer_nip == self.lecturer_nip).first()
         if check_lecturer is not None:
             ret = {
                 'status': 200,
                 'message': 'You have already registered for this course!'
             }
             return ret
         sess.add(self)
         sess.commit()
         new_academic_lecturer = {
             'id': self.id,
             'course_id': self.course_id,
             'course_name': check_course.course_name,
             'course_class': self.course_class,
             'lecturer_nip': self.lecturer_nip,
             'lecturer_credit': self.lecturer_credit,
             'total_credit': self.total_credit,
         }
         ret = {
             'status': 200,
             'message': 'New Academic Lecturer Registered',
             'results': new_academic_lecturer
         }
         return ret
     except Exception as e:
         sess.rollback
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
         sess.close()
예제 #11
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         sess.add(self)
         sess.commit()
         res = {
             'research_id': self.research_id,
             'filepath': self.filepath
         }
         return res
     except Exception as e:
         sess.rollback()
         res = {
             'status': 200,
             'message': e.args
         }
         return res
     finally:
         sess.close()
예제 #12
0
파일: models.py 프로젝트: Kimia-IS/back-end
    def save(self):
        try:
            check_research = sess.query(research).filter(research.lecturer_nip == self.lecturer_nip). \
                filter(research.title == self.title).first()
            if check_research is None:
                sess.add(self)
                sess.commit()

                files = research_file(research_id=self.id, filepath=self.filepath)
                new_research = {
                    'id': self.id,
                    'lecturer_nip': self.lecturer_nip,
                    'title': self.title,
                    'investor': self.investor,
                    'amount': self.amount,
                    'position': self.position,
                    'year': self.year,
                    'term': self.term,
                }
                ret = {
                    'status': 200,
                    'message': 'New Research Registered',
                    'results': [new_research, files.save()]
                }
            else:
                ret = {
                    'status': 200,
                    'message': 'Your research already registered before, please try again another research!'
                }
            return ret
        except Exception as e:
            sess.rollback()
            ret = {
                'status': 200,
                'message': e.args
            }
            return ret
        finally:
            sess.close()
예제 #13
0
 def save(self):
     try:
         check_experience = sess.query(experience).filter(experience.lecturer_nip == self.lecturer_nip).\
             filter(experience.job_name == self.job_name).first()
         if check_experience is None:
             sess.add(self)
             sess.commit()
             new_experience = {
                 'id': self.id,
                 'lecturer_nip': self.lecturer_nip,
                 'job_name': self.job_name,
                 'job_type': self.job_type,
                 'year': self.year,
                 'term': self.term,
                 'filepath': self.filepath
             }
             ret = {
                 'status': 200,
                 'message': 'New Experience Registered',
                 'results': new_experience
             }
         else:
             ret = {
                 'status':
                 200,
                 'message':
                 'Your experience already registered before, please try again another experience!'
             }
         return ret
     except Exception as e:
         sess.rollback()
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
         sess.close()
예제 #14
0
파일: models.py 프로젝트: Kimia-IS/back-end
 def save(self):
     try:
         sess.add(self)
         sess.commit()
         new_final_task_path = {
             'id': self.id,
             'final_task_id': self.final_task_id,
             'file_path': self.file_path,
         }
         ret = {
             'status': 200,
             'message': 'New Final Task File Saved',
             'results': new_final_task_path
         }
         return ret
     except Exception as e:
         sess.rollback()
         ret = {
             'status': 200,
             'message': e.args,
         }
         return ret
     finally:
         sess.close()