john-bodley commented on a change in pull request #7673: Implement data access 
policy modal
URL: 
https://github.com/apache/incubator-superset/pull/7673#discussion_r291775857
 
 

 ##########
 File path: superset/views/core.py
 ##########
 @@ -3000,6 +3000,60 @@ def schemas_access_for_csv_upload(self):
                 'Please contact Superset Admin!\n\n'
                 'The error message returned 
was:\n{}').format(traceback.format_exc()))
 
+    @api
+    @expose('/accept_data_access_policy', methods=['POST'])
+    def accept_data_access_policy(self):
+        """
+        This method exposes and API endpoint to accept the data access policy 
as a user.
+        POST-ing to this api will update the agreed date on the user's 
UserAttribute
+        row.
+        """
+        session = db.session()
+        user_attribute = (
+            session.query(UserAttribute)
+            .filter_by(user_id=g.user.get_id())
+            .one_or_none()
+        )
+        if user_attribute:
+            user_attribute.data_access_policy_agree_date = datetime.now()
+        else:
+            new_user_attribute = UserAttribute(
+                user_id=g.user.get_id(),
+                data_access_policy_agree_date=datetime.now(),
+            )
+            session.add(new_user_attribute)
+
+        session.commit()
+        session.close()
+        return json_success(json.dumps({'status': 'SUCCESS'}))
+
+    def render_template(self, *args, **kwargs):
+        if config.get('ENABLE_DATA_ACCESS_POLICY'):
+            data_access_policy_agree_date = (
+                db.session
 
 Review comment:
   Why not `db.session.query(...)` on the same line for consistency with above?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to