Add possibility to load and dump data with superuser access#129
Add possibility to load and dump data with superuser access#129KhaledBousrih wants to merge 9 commits intoNetsach:masterfrom
Conversation
KhaledBousrih
commented
Apr 21, 2022

| <br> | ||
| {% endif %} | ||
| {% if use_core_automation %} | ||
| <p class="custom-btn" onclick="window.location.href='{{target_admin_view}}';">Go to {{target_admin_view_name}}</p> |
| }; | ||
| function donwloadDump() { | ||
| document.location.href="{% url 'concrete:dump_data' %}?download=true"; | ||
| alert('Your download will begin soon') |
| ] | ||
|
|
||
| if settings.ENABLE_DATABASE_DUMP: | ||
| urlpatterns.append(re_path(r'dump-data', dump_data, name="dump_data")) |
There was a problem hiding this comment.
url names are not dash cased ?
There was a problem hiding this comment.
Both ways are used in the project.
- in
concrete_datastore.api.v1_1.urlswe use the methodget_dashed_case_class_namethat returns dash-cased names (example:my-model) - in
concrete_datastore.routes.urlswe also use dash-cased names (exampleservice-status-view) - in
concrete_datastore.concerte.urlswe use snake-case names (exempleunsubscribe_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) |
|
|
||
| json_resp = json.loads(resp_value) | ||
| return JsonResponse( | ||
| data={'result': json_resp, 'objects_count': len(json_resp)}, |
| response = JsonResponse(data={'message': resp_value}, status=200) | ||
| except Exception as e: | ||
| response = JsonResponse( | ||
| data={'error': f'An error has occured: {e}'}, status=400 |
There was a problem hiding this comment.
should be homogeneous with line 166
| @@ -70,9 +71,20 @@ class DatamodelServer(APIView, TemplateView): | |||
| ) | |||
|
|
|||
| def _get_datamodel_format(self, data_format='yaml'): | |||
There was a problem hiding this comment.
move this to a 'datamodel' module
| return str(value) | ||
|
|
||
| datamodel_content_json = settings.META_MODEL_DEFINITIONS | ||
| if data_format == 'json': |
There was a problem hiding this comment.
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() |
| content = DatamodelYamlToHtml( | ||
| settings.META_MODEL_DEFINITIONS, indent=2 | ||
| ) | ||
| context['yaml_displayed_content'] = content.render_yaml() |
There was a problem hiding this comment.
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" ?
| document.location.href="{% url 'concrete:dump_data' %}?download=true"; | ||
| alert('Your download will begin soon') | ||
| setInterval(()=>{console.log(test)}, 1000) | ||
| // hideWaitingDiv(); |
There was a problem hiding this comment.
Should delete this line if obsolete, or uncomment ?