From 35539c26d45ba2105fa262ad5114de3e6461ba9d Mon Sep 17 00:00:00 2001 From: Jonas Huber Date: Mon, 2 Dec 2024 21:46:19 +0100 Subject: [PATCH 1/5] update changelog --- versions/changelogs/current.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/versions/changelogs/current.md b/versions/changelogs/current.md index 271b0c94e..78a1ecd92 100644 --- a/versions/changelogs/current.md +++ b/versions/changelogs/current.md @@ -4,6 +4,8 @@ - Migrate from django version 3.2 to 5.1 [(#1884)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1884). +- Removed the outdataed & unmaintained references module that was intended to handle bibtex files and store them in a django model [(#1884)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1884). + ## Features ## Bugs From 05a4a6b6cbf35a57dfaf5fa2a808ddffe95456cc Mon Sep 17 00:00:00 2001 From: Jonas Huber Date: Mon, 2 Dec 2024 21:46:43 +0100 Subject: [PATCH 2/5] remove module (unmaintained & feature will be outsourced) --- api/references.py | 230 ---------------------------------------------- 1 file changed, 230 deletions(-) delete mode 100644 api/references.py diff --git a/api/references.py b/api/references.py deleted file mode 100644 index d9b825cb8..000000000 --- a/api/references.py +++ /dev/null @@ -1,230 +0,0 @@ -# coding: utf-8 -import bibtexparser as btp -from sqlalchemy import ( - Boolean, - Column, - ForeignKey, - Integer, - String, - Text, - create_engine, - text, -) -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import Session, relationship - -Base = declarative_base() -metadata = Base.metadata - - -class Entry(Base): - __tablename__ = "entries" - __table_args__ = {"schema": "reference"} - - entries_id = Column( - Integer, - primary_key=True, - server_default=text("nextval('reference.entries_entries_id_seq'::regclass)"), - ) - jabref_eid = Column(String(8), server_default=text("NULL::character varying")) - database_id = Column(ForeignKey("reference.jabref_database.database_id")) - entry_types_id = Column(ForeignKey("reference.entry_types.entry_types_id")) - cite_key = Column(String(100), server_default=text("NULL::character varying")) - abstract = Column(Text) - address = Column(Text) - annote = Column(Text) - author = Column(Text) - booktitle = Column(Text) - chapter = Column(Text) - comment = Column(Text) - crossref = Column(Text) - doi = Column(Text) - edition = Column(Text) - editor = Column(Text) - eid = Column(Text) - file = Column(Text) - howpublished = Column(Text) - institution = Column(Text) - journal = Column(Text) - key_ = Column(Text) - keywords = Column(Text) - language = Column(Text) - location = Column(Text) - month = Column(Text) - note = Column(Text) - number = Column(Text) - organization = Column(Text) - pages = Column(Text) - pdf = Column(Text) - pmid = Column(Text) - priority = Column(Text) - ps = Column(Text) - publisher = Column(Text) - qualityassured = Column(Text) - ranking = Column(Text) - relevance = Column(Text) - school = Column(Text) - search = Column(Text) - series = Column(Text) - title = Column(Text) - type = Column(Text) - url = Column(Text) - volume = Column(Text) - year = Column(Text) - - database = relationship("JabrefDatabase") - entry_types = relationship("EntryType") - - -class EntryType(Base): - __tablename__ = "entry_types" - __table_args__ = {"schema": "reference"} - - entry_types_id = Column( - Integer, - primary_key=True, - server_default=text( - "nextval('reference.entry_types_entry_types_id_seq'::regclass)" - ), - ) - label = Column(Text) - abstract = Column(String(3), server_default=text("NULL::character varying")) - address = Column(String(3), server_default=text("NULL::character varying")) - annote = Column(String(3), server_default=text("NULL::character varying")) - author = Column(String(3), server_default=text("NULL::character varying")) - booktitle = Column(String(3), server_default=text("NULL::character varying")) - chapter = Column(String(3), server_default=text("NULL::character varying")) - comment = Column(String(3), server_default=text("NULL::character varying")) - crossref = Column(String(3), server_default=text("NULL::character varying")) - doi = Column(String(3), server_default=text("NULL::character varying")) - edition = Column(String(3), server_default=text("NULL::character varying")) - editor = Column(String(3), server_default=text("NULL::character varying")) - eid = Column(String(3), server_default=text("NULL::character varying")) - file = Column(String(3), server_default=text("NULL::character varying")) - howpublished = Column(String(3), server_default=text("NULL::character varying")) - institution = Column(String(3), server_default=text("NULL::character varying")) - journal = Column(String(3), server_default=text("NULL::character varying")) - key_ = Column(String(3), server_default=text("NULL::character varying")) - keywords = Column(String(3), server_default=text("NULL::character varying")) - language = Column(String(3), server_default=text("NULL::character varying")) - location = Column(String(3), server_default=text("NULL::character varying")) - month = Column(String(3), server_default=text("NULL::character varying")) - note = Column(String(3), server_default=text("NULL::character varying")) - number = Column(String(3), server_default=text("NULL::character varying")) - organization = Column(String(3), server_default=text("NULL::character varying")) - pages = Column(String(3), server_default=text("NULL::character varying")) - pdf = Column(String(3), server_default=text("NULL::character varying")) - pmid = Column(String(3), server_default=text("NULL::character varying")) - priority = Column(String(3), server_default=text("NULL::character varying")) - ps = Column(String(3), server_default=text("NULL::character varying")) - publisher = Column(String(3), server_default=text("NULL::character varying")) - qualityassured = Column(String(3), server_default=text("NULL::character varying")) - ranking = Column(String(3), server_default=text("NULL::character varying")) - relevance = Column(String(3), server_default=text("NULL::character varying")) - school = Column(String(3), server_default=text("NULL::character varying")) - search = Column(String(3), server_default=text("NULL::character varying")) - series = Column(String(3), server_default=text("NULL::character varying")) - title = Column(String(3), server_default=text("NULL::character varying")) - type = Column(String(3), server_default=text("NULL::character varying")) - url = Column(String(3), server_default=text("NULL::character varying")) - volume = Column(String(3), server_default=text("NULL::character varying")) - year = Column(String(3), server_default=text("NULL::character varying")) - - -class GroupType(Base): - __tablename__ = "group_types" - __table_args__ = {"schema": "reference"} - - group_types_id = Column( - Integer, - primary_key=True, - server_default=text( - "nextval('reference.group_types_group_types_id_seq'::regclass)" - ), - ) - label = Column(String(100), server_default=text("NULL::character varying")) - - -class Group(Base): - __tablename__ = "groups" - __table_args__ = {"schema": "reference"} - - groups_id = Column( - Integer, - primary_key=True, - server_default=text("nextval('reference.groups_groups_id_seq'::regclass)"), - ) - group_types_id = Column(Integer) - label = Column(String(100), server_default=text("NULL::character varying")) - database_id = Column(ForeignKey("reference.jabref_database.database_id")) - parent_id = Column(Integer) - search_field = Column(String(100), server_default=text("NULL::character varying")) - search_expression = Column( - String(200), server_default=text("NULL::character varying") - ) - case_sensitive = Column(Boolean) - reg_exp = Column(Boolean) - hierarchical_context = Column(Integer) - - database = relationship("JabrefDatabase") - - -class JabrefDatabase(Base): - __tablename__ = "jabref_database" - __table_args__ = {"schema": "reference"} - - database_id = Column( - Integer, - primary_key=True, - server_default=text( - "nextval('reference.jabref_database_database_id_seq'::regclass)" - ), - ) - database_name = Column(String(64), nullable=False) - md5_path = Column(String(32), nullable=False) - - -class CommentOnRow: - origin = Column(String(1000), server_default=text("NULL::character varying")) - method = Column(String(1000), server_default=text("NULL::character varying")) - - -# assumptions = Column(JSON) - - -class String(Base): - __tablename__ = "strings" - __table_args__ = {"schema": "reference"} - - strings_id = Column( - Integer, - primary_key=True, - server_default=text("nextval('reference.strings_strings_id_seq'::regclass)"), - ) - label = Column(String(100), server_default=text("NULL::character varying")) - content = Column(String(200), server_default=text("NULL::character varying")) - database_id = Column(ForeignKey("reference.jabref_database.database_id")) - - database = relationship("JabrefDatabase") - - -def read_bibtexfile(file_name): - engine = create_engine("postgres://ckan_perm:H6LgV#C&Mye(arGxQ2B-@localhost/test") - metadata.create_all(bind=engine) - sess = Session(bind=engine) - - with open(file_name, encoding="utf-8") as bibtex_file: - bibtex_database = btp.load(bibtex_file) - for ent in bibtex_database.entries: - props = { - k.name: ent[k.name.replace("entries.", "")] - for k in Entry.__table__.c - if k.name.replace("entries.", "") in ent - } - en = Entry(**props) - sess.add(en) - sess.commit() - - -if __name__ == "__main__": - read_bibtexfile("test.bib") From 2909c8abac556c9b7ae867385e5c52f2a1ca24cd Mon Sep 17 00:00:00 2001 From: Jonas Huber Date: Mon, 2 Dec 2024 21:48:21 +0100 Subject: [PATCH 3/5] update changelog --- versions/changelogs/current.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/changelogs/current.md b/versions/changelogs/current.md index 78a1ecd92..b3cf57279 100644 --- a/versions/changelogs/current.md +++ b/versions/changelogs/current.md @@ -4,7 +4,7 @@ - Migrate from django version 3.2 to 5.1 [(#1884)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1884). -- Removed the outdataed & unmaintained references module that was intended to handle bibtex files and store them in a django model [(#1884)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1884). +- Removed the outdated & unmaintained references module that was intended to handle bibtex files and store them in a django model [(#1913)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1913). ## Features From 1238fcd5718766a62e8e96bcc7ff5692d73fcad7 Mon Sep 17 00:00:00 2001 From: Jonas Huber Date: Mon, 2 Dec 2024 21:51:01 +0100 Subject: [PATCH 4/5] remove deprecated functionality --- api/views.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/api/views.py b/api/views.py index d5c749ee6..0185e6b8c 100644 --- a/api/views.py +++ b/api/views.py @@ -386,7 +386,6 @@ def post(self, request, schema, table): elif "constraint" in json_data["type"]: # Input has nothing to do with DDL from Postgres. # Input is completely different. - # Using actions.parse_sconstd_from_constd is not applicable # dict.get() returns None, if key does not exist constraint_definition = { "action": json_data["action"], # {ADD, DROP} @@ -968,10 +967,10 @@ def get(self, request, schema, table, row_id=None): content_type="text/csv", session=session, ) - response[ - "Content-Disposition" - ] = 'attachment; filename="{schema}__{table}.csv"'.format( - schema=schema, table=table + response["Content-Disposition"] = ( + 'attachment; filename="{schema}__{table}.csv"'.format( + schema=schema, table=table + ) ) return response elif format == "datapackage": @@ -999,10 +998,10 @@ def get(self, request, schema, table, row_id=None): content_type="application/zip", session=session, ) - response[ - "Content-Disposition" - ] = 'attachment; filename="{schema}__{table}.zip"'.format( - schema=schema, table=table + response["Content-Disposition"] = ( + 'attachment; filename="{schema}__{table}.zip"'.format( + schema=schema, table=table + ) ) return response else: From 25bac0d0129fc2504ba65223d5f8716a55bb2ce7 Mon Sep 17 00:00:00 2001 From: Jonas Huber Date: Mon, 2 Dec 2024 21:51:41 +0100 Subject: [PATCH 5/5] remove deprecated functionality --- api/parser.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/api/parser.py b/api/parser.py index 19125d133..d99d5933b 100644 --- a/api/parser.py +++ b/api/parser.py @@ -671,29 +671,6 @@ def parse_scolumnd_from_columnd(schema, table, name, column_description): } -def parse_sconstd_from_constd(schema, table, name_const, constraint_description): - defi = constraint_description.get("definition") - return { - "action": None, # {ADD, DROP} - "constraint_type": constraint_description.get( - "constraint_typ" - ), # {FOREIGN KEY, PRIMARY KEY, UNIQUE, CHECK} - "constraint_name": name_const, - "constraint_parameter": constraint_description.get("definition") - .split("(")[1] - .split(")")[0], - # Things in Brackets, e.g. name of column - "reference_table": defi.split("REFERENCES ")[1].split("(")[2] - if "REFERENCES" in defi - else None, - "reference_column": defi.split("(")[2].split(")")[1] - if "REFERENCES" in defi - else None, - "c_schema": schema, - "c_table": table, - } - - def replace_None_with_NULL(dictonary): # Replacing None with null for Database for key, value in dictonary.items():