always save collections in user folder (#4336)
This commit is contained in:
parent
1114259d2d
commit
51bc80c105
|
@ -48,8 +48,6 @@ class Collection(Container):
|
|||
|
||||
class ISaveForm(Interface):
|
||||
title = schema.TextLine(title=_(u'Title'), required=True)
|
||||
save_location = RelationChoice(title=_(u'Save Location'), required=True,
|
||||
source=ObjPathSourceBinder())
|
||||
|
||||
|
||||
class SaveForm(z3c_form.Form):
|
||||
|
@ -66,17 +64,15 @@ class View(form.DisplayForm):
|
|||
schema = ICollection
|
||||
|
||||
def update(self):
|
||||
if not 'save_location' in self.fields:
|
||||
if not 'title' in self.fields:
|
||||
self.fields += field.Fields(ISaveForm)
|
||||
super(View, self).update()
|
||||
|
||||
def updateWidgets(self):
|
||||
if not 'save_location' in self.fields:
|
||||
if not 'title' in self.fields:
|
||||
self.fields += field.Fields(ISaveForm)
|
||||
self.fields['title'].ignoreContext = True
|
||||
self.fields['title'].ignoreRequest = True
|
||||
self.fields['save_location'].ignoreContext = True
|
||||
self.fields['save_location'].ignoreRequest = True
|
||||
form.DisplayForm.updateWidgets(self)
|
||||
|
||||
if self.widgets['query'].value:
|
||||
|
|
|
@ -353,10 +353,8 @@ function select_metatype(elem)
|
|||
|
||||
if ($('#pfwbsearchform .error').length == 0) {
|
||||
$('#formfield-form-widgets-title').hide();
|
||||
$('#formfield-form-widgets-save_location').hide();
|
||||
$('#form-buttons-save').click(function() {
|
||||
$('#formfield-form-widgets-title').show();
|
||||
$('#formfield-form-widgets-save_location').show();
|
||||
$(this).unbind('click');
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from collections import OrderedDict
|
||||
import json
|
||||
|
||||
from Products.CMFPlone.utils import base_hasattr
|
||||
|
||||
from plone import api
|
||||
from plone.dexterity.utils import createContentInContainer
|
||||
from five import grok
|
||||
|
@ -52,8 +54,6 @@ class ISearchForm(Interface):
|
|||
sort_reversed = schema.Bool(default=False)
|
||||
|
||||
title = schema.TextLine(title=_(u'Title'), required=True)
|
||||
save_location = RelationChoice(title=_(u'Save Location'), required=True,
|
||||
source=ObjPathSourceBinder())
|
||||
|
||||
|
||||
class SearchForm(form.Form):
|
||||
|
@ -66,9 +66,21 @@ class SearchForm(form.Form):
|
|||
@button.buttonAndHandler(_(u'Save'))
|
||||
def handleApply(self, action):
|
||||
data, errors = self.extractData()
|
||||
location = data.get('save_location')
|
||||
if not location or not data.get('title'):
|
||||
if not data.get('title'):
|
||||
return
|
||||
|
||||
current = plone.api.user.get_current()
|
||||
# When Anonymous current.id == 'acl_users' and current.getId() is None
|
||||
current_id = current.getId()
|
||||
if current_id is None:
|
||||
return
|
||||
|
||||
members_folder = getattr(plone.api.portal.get(), 'Members')
|
||||
if base_hasattr(members_folder, current_id):
|
||||
location = getattr(members_folder, current_id)
|
||||
else:
|
||||
return
|
||||
|
||||
item = createContentInContainer(location, 'pfwbgedcollection',
|
||||
title=data.get('title'),
|
||||
query=data.get('query'),
|
||||
|
|
Reference in New Issue