[ckan-changes] [okfn/ckan] 6002a5: [2347] Restrict updates/create of related featured...

GitHub noreply at github.com
Thu May 3 10:39:34 UTC 2012


  Branch: refs/heads/feature-2347-related-dashboard
  Home:   https://github.com/okfn/ckan
  Commit: 6002a53a6be3c9a1d9a5940a05377d7f8233d5bc
      https://github.com/okfn/ckan/commit/6002a53a6be3c9a1d9a5940a05377d7f8233d5bc
  Author: Ross Jones <rossdjones at gmail.com>
  Date:   2012-05-03 (Thu, 03 May 2012)

  Changed paths:
    M ckan/logic/action/create.py
    M ckan/logic/action/update.py
    M ckan/logic/schema.py
    M ckan/templates/related/dashboard.html

  Log Message:
  -----------
  [2347] Restrict updates/create of related featured flag to admins for now


diff --git a/ckan/logic/action/create.py b/ckan/logic/action/create.py
index aee73a3..5da99b6 100644
--- a/ckan/logic/action/create.py
+++ b/ckan/logic/action/create.py
@@ -1,6 +1,7 @@
 import logging
 from pylons.i18n import _
 
+import ckan.authz as authz
 import ckan.lib.plugins as lib_plugins
 import ckan.logic as logic
 import ckan.rating as ratings
@@ -126,6 +127,11 @@ def related_create(context, data_dict):
         model.Session.rollback()
         raise ValidationError(errors, error_summary(errors))
 
+    # Only sys admins can update a related item to make it 1
+    if not authz.Authorizer().is_sysadmin(unicode(user)):
+        data['featured'] = 0
+
+
     related = model_save.related_dict_save(data, context)
     if not context.get('defer_commit'):
         model.repo.commit_and_remove()
diff --git a/ckan/logic/action/update.py b/ckan/logic/action/update.py
index cd5aa2f..3b839d0 100644
--- a/ckan/logic/action/update.py
+++ b/ckan/logic/action/update.py
@@ -4,6 +4,7 @@
 from pylons.i18n import _
 from vdm.sqlalchemy.base import SQLAlchemySession
 
+import ckan.authz as authz
 import ckan.plugins as plugins
 import ckan.logic as logic
 import ckan.logic.schema
@@ -120,6 +121,10 @@ def related_update(context, data_dict):
         model.Session.rollback()
         raise ValidationError(errors, error_summary(errors))
 
+    # Only sys admins can update a related item to make it 1
+    if not authz.Authorizer().is_sysadmin(unicode(user)):
+        data['featured'] = 0
+
     related = model_save.related_dict_save(data, context)
     if not context.get('defer_commit'):
         model.repo.commit()
diff --git a/ckan/logic/schema.py b/ckan/logic/schema.py
index 09ffe22..4c174e7 100644
--- a/ckan/logic/schema.py
+++ b/ckan/logic/schema.py
@@ -245,6 +245,7 @@ def default_related_schema():
         'url': [ignore_missing, unicode],
         'owner_id': [not_empty, unicode],
         'created': [ignore],
+        'featured': [ignore_missing, unicode],
     }
     return schema
 
diff --git a/ckan/templates/related/dashboard.html b/ckan/templates/related/dashboard.html
index aa1f0fb..39b4664 100644
--- a/ckan/templates/related/dashboard.html
+++ b/ckan/templates/related/dashboard.html
@@ -14,7 +14,7 @@
   <py:def function="body_class">no-sidebar</py:def>
   <xi:include href="add-related.html" />
 
-  <py:def function="page_title">Apps</py:def>
+  <py:def function="page_title">Application</py:def>
 
   <py:def function="page_heading" property="dc:title">
     Applications


================================================================



More information about the ckan-changes mailing list