Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comments: add notes for refactoring #1

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading