def add_teacher_to_db(self, url, attributes, departments_from_db_q): name = attributes[0] email = attributes[1] try: department = departments_from_db_q.get(name = attributes[2]) except Exception as error: logger_syslog.error(error, extra = log_extra_data(url)) logger_mail.exception(error) return teacher = Teachers( url = url, name = name, email = email, department = department, ) try: teacher.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) author = Authors(content_object = teacher) author.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) except IntegrityError: ''' Check if the entry is already in the DB but marked inactive ''' teacher = Teachers.objects.filter(is_active=False).get(url=url) teacher.is_active = True teacher.save() logger_syslog.info(u'Αλλαγή κατάστασης σε active', extra = log_extra_data(url)) except Exception as error: logger_syslog.error(error, extra = log_extra_data(url)) logger_mail.exception(error) return
def add_faculty_to_db(self, url, attributes): name = attributes[0] code = attributes[1] faculty = EclassFaculties( url = url, name = name, code = code, ) try: faculty.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) author = Authors(content_object = faculty) author.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) except IntegrityError: ''' Check if the entry is already in the DB but marked inactive ''' faculty = EclassFaculties.objects.filter(is_active=False).get(url=url) faculty.is_active = True faculty.save() logger_syslog.info(u'Αλλαγή κατάστασης σε active', extra = log_extra_data(url)) except Exception as error: logger_syslog.error(error, extra = log_extra_data(url)) logger_mail.exception(error) return
def add_website_to_db(self, url, attributes): ''' Add the website to the DB ''' name = attributes[0] rss = attributes[1] email = attributes[2] website = Websites( url = url, name = name, rss = rss, email = email, ) try: website.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) author = Authors(content_object = website) author.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) except IntegrityError: ''' Check if the entry is already in the DB but marked inactive ''' website = Websites.objects.filter(is_active=False).get(url=url) website.is_active = True website.save() logger_syslog.info(u'Αλλαγή κατάστασης σε active', extra = log_extra_data(url)) except Exception as error: logger_syslog.error(error, extra = log_extra_data(url)) logger_mail.exception(error) return
def add_lesson_to_db(self, url, attributes, faculties_from_db_q): name = attributes[0] teacher = attributes[1] faculty = faculties_from_db_q.get(name = attributes[2]) ltype = attributes[3] lesson = EclassLessons( url = url, name = name, teacher = teacher, faculty = faculty, ltype = ltype, ) try: lesson.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) author = Authors(content_object = lesson) author.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) except IntegrityError: ''' Check if the entry is already in the DB but marked inactive ''' lesson = EclassLessons.objects.filter(is_active=False).get(url=url) lesson.is_active = True lesson.save() logger_syslog.info(u'Αλλαγή κατάστασης σε active', extra = log_extra_data(url)) except Exception as error: logger_syslog.error(error, extra = log_extra_data(url)) logger_mail.exception(error) return
def add_department_to_db(self, url, name): department = Departments(url=url, name=name) try: department.save() logger_syslog.info(u"Επιτυχής προσθήκη", extra=log_extra_data(url)) author = Authors(content_object=department) author.save() logger_syslog.info(u"Επιτυχής προσθήκη", extra=log_extra_data(url)) except IntegrityError: """ Check if the entry is already in the DB but marked inactive """ department = Departments.objects.filter(is_active=False).get(url=url) department.is_active = True department.save() logger_syslog.info(u"Αλλαγή κατάστασης σε active", extra=log_extra_data(url)) except Exception as error: logger_syslog.error(error, extra=log_extra_data(url)) logger_mail.exception(error) return