add sync of blocked documents (remove them from website)
This commit is contained in:
parent
ca7e7a4be6
commit
67a679f50b
|
@ -31,6 +31,14 @@
|
|||
permission="zope2.View"
|
||||
/>
|
||||
|
||||
<browser:view
|
||||
name="listBlockedDocuments"
|
||||
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
|
||||
class=".views.ListBlockedDocuments"
|
||||
permission="zope2.View"
|
||||
/>
|
||||
|
||||
|
||||
<browser:view
|
||||
name="listCommissions"
|
||||
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
|
||||
|
|
|
@ -40,7 +40,8 @@ class SyncFromThemis(UtilityView):
|
|||
|
||||
timestamp = self.request.form.get('timestamp')
|
||||
objects = self.request.form.get('objects', '').split(',')
|
||||
for object in ('deputies', 'ministries', 'commissions', 'documents'):
|
||||
for object in ('deputies', 'ministries', 'commissions', 'documents',
|
||||
'blocked_documents'):
|
||||
if not 'all' in objects:
|
||||
if not object in objects:
|
||||
continue
|
||||
|
@ -305,3 +306,31 @@ class SyncFromThemis(UtilityView):
|
|||
transaction.commit()
|
||||
|
||||
print 'documents done'
|
||||
|
||||
def sync_blocked_documents(self, timestamp=None):
|
||||
qs = ''
|
||||
if timestamp:
|
||||
qs = '?timestamp=%s' % timestamp
|
||||
print 'loading blocked documents list from', self.src_url
|
||||
documents = json.load(self.urlopen('%s/@@listBlockedDocuments%s' % (self.src_url, qs)))
|
||||
print 'done'
|
||||
|
||||
for count, document_url in enumerate(documents):
|
||||
print 'loading', document_url
|
||||
data = json.load(self.urlopen('%s/json' % document_url))
|
||||
|
||||
new_id = data.get('id')
|
||||
is_question = False
|
||||
if data.get('portal_type') in ('Question_ecriteD',
|
||||
'questionactualiteD', 'QuestionoraleD',
|
||||
'interpellationD'):
|
||||
if hasattr(self.questions_folder, new_id):
|
||||
self.questions_folder.manage_delObject(new_id)
|
||||
else:
|
||||
if hasattr(self.documents_folder, new_id):
|
||||
self.documents_folder.manage_delObject(new_id)
|
||||
|
||||
if count % 100 == 0:
|
||||
transaction.commit()
|
||||
|
||||
print 'blocked documents done'
|
||||
|
|
|
@ -73,6 +73,25 @@ class ListDocuments(UtilityView):
|
|||
return json.dumps(l)
|
||||
|
||||
|
||||
class ListBlockedDocuments(UtilityView):
|
||||
def __call__(self):
|
||||
self.setup()
|
||||
timestamp = self.request.form.get('timestamp')
|
||||
kw = {}
|
||||
if timestamp:
|
||||
kw['modified'] = {'query': DateTime(timestamp), 'range': 'min'}
|
||||
|
||||
folder_path = '/'.join(getattr(self.portal, 'documents-diffusables').getPhysicalPath())
|
||||
l = []
|
||||
for brain in self.catalog(review_state='blocked', path={'query': folder_path}, **kw):
|
||||
if brain.portal_type in ('Folder', 'Topic'):
|
||||
continue
|
||||
l.append(brain.getObject().absolute_url())
|
||||
self.request.response.setHeader('Content-type', 'application/json')
|
||||
return json.dumps(l)
|
||||
|
||||
|
||||
|
||||
class ListCommissions(UtilityView):
|
||||
def __call__(self):
|
||||
self.setup()
|
||||
|
|
Reference in New Issue