-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from imatem/addForms
Add forms
- Loading branch information
Showing
8 changed files
with
190 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# from collective.judgment import _ | ||
from Acquisition import aq_inner | ||
from plone.dexterity.browser.add import DefaultAddForm | ||
from plone.dexterity.browser.add import DefaultAddView | ||
from plone.dexterity.interfaces import IDexterityFTI | ||
from plone.dexterity.utils import addContentToContainer | ||
from zope.component import getUtility | ||
|
||
|
||
class PdfFileAddForm(DefaultAddForm): | ||
portal_type = 'Pdf File' | ||
|
||
def add(self, object): | ||
|
||
fti = getUtility(IDexterityFTI, name=self.portal_type) | ||
container = aq_inner(self.context) | ||
new_object = addContentToContainer(container, object) | ||
|
||
parentfti = getUtility(IDexterityFTI, name=container.portal_type) | ||
|
||
if parentfti.immediate_view: | ||
self.immediate_view = "/".join( | ||
[container.absolute_url(), fti.immediate_view] | ||
) | ||
else: | ||
self.immediate_view = "/".join( | ||
[container.absolute_url(), ] | ||
) | ||
|
||
|
||
class PdfFileAddView(DefaultAddView): | ||
form = PdfFileAddForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
from zope.component import getUtility | ||
from plone.dexterity.browser.edit import DefaultEditForm | ||
from plone.registry.interfaces import IRegistry | ||
|
||
|
||
class EditForm(DefaultEditForm): | ||
|
||
def nextURL(self): | ||
view_url = self.context.aq_parent.absolute_url() | ||
portal_type = getattr(self.context.aq_parent, 'portal_type', None) | ||
if portal_type is not None: | ||
registry = getUtility(IRegistry) | ||
use_view_action = registry.get( | ||
'plone.types_use_view_action_in_listings', []) | ||
if portal_type in use_view_action: | ||
view_url = view_url + '/view' | ||
return view_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/collective/judgment/profiles/default/types/Pdf_File.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0"?> | ||
<object | ||
i18n:domain="collective.judgment" | ||
meta_type="Dexterity FTI" | ||
name="Pdf File" | ||
xmlns:i18n="http://xml.zope.org/namespaces/i18n"> | ||
|
||
<!-- Basic properties --> | ||
<property | ||
i18n:translate="" | ||
name="title">Pdf File</property> | ||
<property | ||
i18n:translate="" | ||
name="description">Lets you upload a file to the site.</property> | ||
|
||
<property name="allow_discussion">False</property> | ||
<property name="factory">Pdf File</property> | ||
<property name="icon_expr"></property> | ||
<property name="link_target"></property> | ||
|
||
<!-- Hierarchy control --> | ||
<property name="allowed_content_types"/> | ||
<property name="filter_content_types">True</property> | ||
<property name="global_allow">False</property> | ||
|
||
<!-- Schema, class and security --> | ||
<property name="add_permission">collective.judgment.AddPromotion</property> | ||
<property name="klass">collective.judgment.content.files.PdfFile</property> | ||
<property name="model_file"></property> | ||
<property name="model_source"></property> | ||
<property name="schema">collective.judgment.content.files.IPdfFile</property> | ||
|
||
<!-- Enabled behaviors --> | ||
<property name="behaviors" purge="false"> | ||
<!-- <element value="plone.app.dexterity.behaviors.metadata.ICategorization"/> --> | ||
<!-- <element value="plone.app.dexterity.behaviors.metadata.IPublication"/> --> | ||
<!-- <element value="plone.app.dexterity.behaviors.metadata.IOwnership"/> --> | ||
<element value="plone.app.dexterity.behaviors.filename.INameFromFileName"/> | ||
<element value="plone.app.dexterity.behaviors.discussion.IAllowDiscussion"/> | ||
<!-- <element value="plone.app.dexterity.behaviors.id.IShortName"/> --> | ||
<!-- <element value="plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation"/> --> | ||
<!-- <element value="plone.app.relationfield.behavior.IRelatedItems"/> --> | ||
</property> | ||
|
||
<!-- View information --> | ||
<property name="add_view_expr">string:${folder_url}/++add++Pdf File</property> | ||
<property name="default_view">file_view</property> | ||
<property name="default_view_fallback">False</property> | ||
<property name="immediate_view">view</property> | ||
<property name="view_methods"> | ||
<element value="file_view"/> | ||
</property> | ||
|
||
<!-- Method aliases --> | ||
<alias | ||
from="(Default)" | ||
to="@@display-file" | ||
/> | ||
<alias | ||
from="edit" | ||
to="@@edit" | ||
/> | ||
<alias | ||
from="sharing" | ||
to="@@sharing" | ||
/> | ||
<alias | ||
from="view" | ||
to="(selected layout)" | ||
/> | ||
|
||
<!-- Actions --> | ||
<action | ||
action_id="view" | ||
category="object" | ||
condition_expr="" | ||
i18n:attributes="title" | ||
title="View" | ||
url_expr="string:${object_url}/view" | ||
visible="True"> | ||
<permission value="View"/> | ||
</action> | ||
<action | ||
action_id="edit" | ||
category="object" | ||
condition_expr="" | ||
i18n:attributes="title" | ||
title="Edit" | ||
url_expr="string:${object_url}/edit" | ||
visible="True"> | ||
<permission value="Modify portal content"/> | ||
</action> | ||
|
||
</object> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters