Repository: OpenEnergyPlatform/oeplatform

Issue:
[DataView] Add "publish" functionality to tablepage / profile page.
## Description of the problem

We are planning to develop a sophisticated process for publishing data, but it will take more time. By publishing, we mean moving a data source (table object) from the "model_draft" to its own topic that matches the scope of the data. We use a peer review to check if the metadata and also the structure of the data is suitable for the OEP. 

Since we already provide a RestAPI endpoint that allows users with access rights to move a table between topics, we would like to provide a button that increases the visibility of this functionality to the user. This button will initially be visible on the table page and could be moved to the data publishing view once available.

## Possible solutions.

We don't want anyone to "publish" their data to the OEP without quality control. Therefore, we should include some checks that need to be implemented in the "move" API endpoint. These checks will ensure that the data complies with our policies and can be published without legal liabilities.

Checks:
- is table reviewed? (reviews can be completed, but result is not applied to the oemetadata json so far #1358 )
- is table already in topic (might not be possible as tables are unique and topic are linked to the table object)
- more ????

Use cases:
- is table in model_draft (publish - data cant be edited)
- is table in other topic (move to model draft in order to update data and publish next version / reupload and remove version)


## Workflow checklist
- [ ] I am aware of the workflow in [CONTRIBUTING.md](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/CONTRIBUTING.md)



Discussion:

Resolving patch:
diff --git a/api/actions.py b/api/actions.py
--- a/api/actions.py
+++ b/api/actions.py
@@ -1523,8 +1523,9 @@ def move(from_schema, table, to_schema):
         session.query(OEDBTableTags).filter(
             OEDBTableTags.schema_name == from_schema, OEDBTableTags.table_name == table
         ).update({OEDBTableTags.schema_name: to_schema})
+        t.set_is_published()
         session.commit()
-        t.save()
+        # t.save()
     except Exception:
         session.rollback()
         raise
@@ -1532,6 +1533,10 @@ def move(from_schema, table, to_schema):
         session.close()
 
 
+
+
+
+
 def create_meta(schema, table):
     # meta_schema = get_meta_schema_name(schema)
 
diff --git a/api/urls.py b/api/urls.py
--- a/api/urls.py
+++ b/api/urls.py
@@ -1,4 +1,5 @@
 from django.conf.urls import url
+from django.urls import path
 
 from api import actions, views
 
@@ -20,11 +21,7 @@
         views.Metadata.as_view(),
         name="api_table_meta",
     ),
-    url(
-        r"^v0/schema/(?P<schema>[\w\d_\s]+)/tables/(?P<table>[\w\d_\s]+)/move/(?P<to_schema>[\w\d_\s]+)/$",  # noqa
-        views.Move.as_view(),
-        name="move",
-    ),
+    path('v0/schema/<str:schema>/tables/<str:table>/move/<str:to_schema>/', views.Move.as_view(), name ='move'),
     url(
         r"^v0/schema/(?P<schema>[\w\d_\s]+)/tables/(?P<table>[\w\d_\s]+)/columns/(?P<column>[\w\d_\s]+)?$",  # noqa
         views.Column.as_view(),


Test patch: