Skip to content

Commit

Permalink
comments: add notes for refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
MyPyDavid committed Oct 18, 2024
1 parent d267f4f commit d1665bc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions MaRDMO/citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from pylatexenc.latex2text import LatexNodes2Text
from langdetect import detect

# TODO this class can be refactored in a couple of pydantic schema models
# TODO requests can be raised_for_status
# TODO lang_dict load can go to a utils func with load_from_json(data/lang.json)

def GetCitation(doi):
'''Function gets citation by DOI'''

Expand Down
5 changes: 5 additions & 0 deletions MaRDMO/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# this should be refactored into one Config object,
# it could be simple dict, or configDict, or BaseModel
# and then all the configuration settings should be collected here
# maybe reuse the django.conf settings

#RDMO BASE URI
BASE_URI = 'https://rdmo.mardi4nfdi.de/terms/'

Expand Down
11 changes: 6 additions & 5 deletions MaRDMO/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
from .handlers import Author_Search
from .mathmoddb import ModelRetriever

try:
try: # TODO move to confing
# Get login credentials if available
from config.settings import lgname, lgpassword
except:
lgname=''; lgpassword=''

try:
try: # TODO move to confing
# Get login credentials if available
from config.settings import mathmoddb_username, mathmoddb_password
except:
Expand All @@ -40,14 +40,15 @@ def render(self):
(adjusted from csv export)'''

### Check if MaRDI Questionaire is used ###########################################################################################################################################################

# TODO refactor into separate validation
if str(self.project.catalog)[-6:] != 'MaRDMO':
return render(self.request,'MaRDMO/workflowError.html', {
'error': 'Questionnaire \'{}\' not suitable for MaRDI Export!'.format(str(self.project.catalog).split('/')[-1])
}, status=200)

### Load MaRDMO Options ##########################################################################################################################################################################

# TODO make a utils func for json and load in a separate func
# TODO add schema models for these dicts
path = os.path.join(os.path.dirname(__file__), 'data', 'questions.json')
with open(path, "r") as json_file:
questions = json.load(json_file)
Expand Down Expand Up @@ -83,7 +84,7 @@ def render(self):
if answers['Settings'].get('Documentation') == option['Document']:

### Checks for Workflow Documentation #############################################################################################################################################################

# TODO refactor into separate validation, checks are validations
# Export Type
if not answers['Settings'].get('Public'):
# Stop if no Documentation Type chosen
Expand Down

0 comments on commit d1665bc

Please sign in to comment.