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_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)) except Exception as error: logger_syslog.error(error, extra = log_extra_data(url)) logger_mail.exception(error) return author = Authors(content_object = faculty) try: author.save() logger_syslog.info(u'Επιτυχής προσθήκη', extra = log_extra_data(url)) except Exception as error: logger_syslog.error(error, extra = log_extra_data(url)) logger_mail.exception(error) return