Skip to content

Add possibility to load and dump data with superuser access#129

Draft
KhaledBousrih wants to merge 9 commits intoNetsach:masterfrom
KhaledBousrih:feature-loaddata-dumpdata
Draft

Add possibility to load and dump data with superuser access#129
KhaledBousrih wants to merge 9 commits intoNetsach:masterfrom
KhaledBousrih:feature-loaddata-dumpdata

Conversation

@KhaledBousrih
Copy link
Copy Markdown
Collaborator

image

<br>
{% endif %}
{% if use_core_automation %}
<p class="custom-btn" onclick="window.location.href='{{target_admin_view}}';">Go to {{target_admin_view_name}}</p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a <a href= here

};
function donwloadDump() {
document.location.href="{% url 'concrete:dump_data' %}?download=true";
alert('Your download will begin soon')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not use alert

]

if settings.ENABLE_DATABASE_DUMP:
urlpatterns.append(re_path(r'dump-data', dump_data, name="dump_data"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url names are not dash cased ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both ways are used in the project.

  • in concrete_datastore.api.v1_1.urls we use the method get_dashed_case_class_name that returns dash-cased names (example: my-model)
  • in concrete_datastore.routes.urls we also use dash-cased names (example service-status-view)
  • in concrete_datastore.concerte.urls we use snake-case names (exemple unsubscribe_notifications_result)

Since the code added is in the module concrete_datastore.concerte.urls I tried to keep the same naming convention of this module.

Should we homogenize the names of all the urls into dash-cased names ?

status=200,
)
except Exception as e:
return JsonResponse(data={'error': str(e)}, status=400)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a log is required here


json_resp = json.loads(resp_value)
return JsonResponse(
data={'result': json_resp, 'objects_count': len(json_resp)},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

results would be better

response = JsonResponse(data={'message': resp_value}, status=200)
except Exception as e:
response = JsonResponse(
data={'error': f'An error has occured: {e}'}, status=400
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be homogeneous with line 166

@@ -70,9 +71,20 @@ class DatamodelServer(APIView, TemplateView):
)

def _get_datamodel_format(self, data_format='yaml'):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to a 'datamodel' module

return str(value)

datamodel_content_json = settings.META_MODEL_DEFINITIONS
if data_format == 'json':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too light about data_format validation

datamodel_content_json = settings.META_MODEL_DEFINITIONS
context['json_content'] = json.dumps(datamodel_content_json, indent=2)
datamodel_content_json = self._get_datamodel_format(data_format='json')
datamodel_content_yml = self._get_datamodel_format()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify format here

content = DatamodelYamlToHtml(
settings.META_MODEL_DEFINITIONS, indent=2
)
context['yaml_displayed_content'] = content.render_yaml()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class is named Yaml to Html, but only function "render yaml" is called, a yaml is expected as a result.
So based on the class name "YAML to HTML", but based on parameters and function names "JSON to YAML" ?

@KhaledBousrih KhaledBousrih marked this pull request as draft October 19, 2022 13:28
document.location.href="{% url 'concrete:dump_data' %}?download=true";
alert('Your download will begin soon')
setInterval(()=>{console.log(test)}, 1000)
// hideWaitingDiv();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should delete this line if obsolete, or uncomment ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants