Removed toplevel Avis type, and moved back general infos and odt generation to
sub avis.
This commit is contained in:
parent
7eccda9752
commit
b9cebe9b2f
86
Avis.py
86
Avis.py
|
@ -26,93 +26,16 @@ import time
|
|||
import appy.pod.renderer
|
||||
from DateTime import DateTime
|
||||
|
||||
from AccessControl import ClassSecurityInfo
|
||||
from Products.Archetypes.atapi import *
|
||||
from Products.CMFPlone.interfaces.NonStructuralFolder import INonStructuralFolder
|
||||
|
||||
from config import *
|
||||
|
||||
schema = Schema((
|
||||
|
||||
# Attributs liés au texte en projet ----------------------------------------
|
||||
|
||||
StringField(
|
||||
name='apType',
|
||||
widget=SelectionWidget(
|
||||
label="Type de norme",
|
||||
format="select",
|
||||
label_msgid='Avis_label_apType',
|
||||
i18n_domain='Avis',
|
||||
),
|
||||
enforceVocabulary=True,
|
||||
vocabulary=DisplayList(( ('arreteGouv', u'arrêté du Gouvernement wallon'),
|
||||
('arreteMin', u'arrêté ministériel'),
|
||||
('decret', u'décret') )),
|
||||
required=True
|
||||
),
|
||||
|
||||
StringField(
|
||||
name='apTitle',
|
||||
widget=TextAreaWidget(
|
||||
label=u"Intitulé de la norme",
|
||||
rows=3,
|
||||
label_msgid='Avis_label_apTitle',
|
||||
i18n_domain='Avis',
|
||||
),
|
||||
required=True
|
||||
),
|
||||
|
||||
StringField(
|
||||
name='apDescription',
|
||||
widget=TextAreaWidget(
|
||||
label=u"Contexte",
|
||||
rows=5,
|
||||
label_msgid='Avis_label_apDescription',
|
||||
i18n_domain='Avis',
|
||||
)
|
||||
),
|
||||
|
||||
),
|
||||
)
|
||||
|
||||
Avis_schema = OrderedBaseFolderSchema.copy() + \
|
||||
schema.copy()
|
||||
|
||||
class Avis(OrderedBaseFolder):
|
||||
'''Folder that contain the different parts of an Avis'''
|
||||
security = ClassSecurityInfo()
|
||||
__implements__ = OrderedBaseFolder.__implements__ + (INonStructuralFolder,)
|
||||
|
||||
# This name appears in the 'add' box
|
||||
archetype_name = "Avis"
|
||||
meta_type = 'Avis'
|
||||
portal_type = 'Avis'
|
||||
allowed_content_types = ['AvisSimplif', 'AvisLegis']
|
||||
filter_content_types = 1
|
||||
global_allow = 1
|
||||
content_icon = 'avis_icon.gif'
|
||||
immediate_view = 'base_view'
|
||||
default_view = 'base_view'
|
||||
suppl_views = ()
|
||||
typeDescription = "Avis"
|
||||
typeDescMsgId = 'description_edit_avis'
|
||||
|
||||
_at_rename_after_creation = True
|
||||
schema = Avis_schema
|
||||
|
||||
actions = (
|
||||
{'action': "string:$object_url/generateOdt",
|
||||
'id': 'asOdt',
|
||||
'name': u'Générer en ODT',
|
||||
'permissions': ("View",),
|
||||
'condition': 'python:1'
|
||||
},
|
||||
)
|
||||
class AvisOdt:
|
||||
'''Base class for common methods of Avis'''
|
||||
|
||||
def canSetDefaultPage(self):
|
||||
return False
|
||||
|
||||
security.declarePublic('generateOdt')
|
||||
def generateOdt(self, RESPONSE):
|
||||
'''Generates the ODT version of this advice.'''
|
||||
return self._generate(RESPONSE, 'odt')
|
||||
|
@ -124,7 +47,7 @@ class Avis(OrderedBaseFolder):
|
|||
tempFileName = '/tmp/%s.%f.%s' % (self._at_uid, time.time(),
|
||||
fileType)
|
||||
renderer = appy.pod.renderer.Renderer(
|
||||
'%s/Avis.odt' % os.path.dirname(__file__),
|
||||
'%s/%s.odt' % (os.path.dirname(__file__), self.portal_type),
|
||||
{'avis': self}, tempFileName)
|
||||
renderer.run()
|
||||
# Tell the browser that the resulting page contains PDF
|
||||
|
@ -156,6 +79,3 @@ class Avis(OrderedBaseFolder):
|
|||
now = DateTime()
|
||||
return now.strftime('%d/%m/%Y')
|
||||
|
||||
|
||||
|
||||
registerType(Avis, PROJECTNAME)
|
||||
|
|
|
@ -41,7 +41,7 @@ class AvisFolder(OrderedBaseFolder):
|
|||
archetype_name = "Dossier d'avis"
|
||||
meta_type = 'AvisFolder'
|
||||
portal_type = 'AvisFolder'
|
||||
allowed_content_types = ['Avis', 'AvisFolder']
|
||||
allowed_content_types = ['AvisSimplif', 'AvisLegis', 'AvisFolder']
|
||||
filter_content_types = 1
|
||||
global_allow = 1
|
||||
#content_icon = 'AvisFolder.gif'
|
||||
|
|
52
AvisLegis.py
52
AvisLegis.py
|
@ -29,6 +29,8 @@ import os, time, os.path
|
|||
import appy.pod.renderer
|
||||
from Products.MasterSelectWidget.MasterSelectWidget import MasterSelectWidget
|
||||
|
||||
from Avis import AvisOdt
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
def slaveFields(action, *slaves):
|
||||
'''Helps to define more smartly the slave fields of a master field
|
||||
|
@ -815,6 +817,46 @@ elle est jointe.'''
|
|||
|
||||
schema = Schema((
|
||||
|
||||
# Attributs liés au texte en projet ----------------------------------------
|
||||
|
||||
StringField(
|
||||
name='apType',
|
||||
widget=SelectionWidget(
|
||||
label="Type de norme",
|
||||
format="select",
|
||||
label_msgid='Avis_label_apType',
|
||||
i18n_domain='Avis',
|
||||
),
|
||||
enforceVocabulary=True,
|
||||
vocabulary=DisplayList(( ('arreteGouv', u'arrêté du Gouvernement wallon'),
|
||||
('arreteMin', u'arrêté ministériel'),
|
||||
('decret', u'décret') )),
|
||||
required=True
|
||||
),
|
||||
|
||||
StringField(
|
||||
name='apTitle',
|
||||
widget=TextAreaWidget(
|
||||
label=u"Intitulé de la norme",
|
||||
rows=3,
|
||||
label_msgid='Avis_label_apTitle',
|
||||
i18n_domain='Avis',
|
||||
),
|
||||
required=True
|
||||
),
|
||||
|
||||
StringField(
|
||||
name='apDescription',
|
||||
widget=TextAreaWidget(
|
||||
label=u"Contexte",
|
||||
rows=5,
|
||||
label_msgid='Avis_label_apDescription',
|
||||
i18n_domain='Avis',
|
||||
)
|
||||
),
|
||||
|
||||
# Q and A
|
||||
|
||||
StringField(
|
||||
name='directive',
|
||||
widget=MasterSelectWidget(
|
||||
|
@ -3767,19 +3809,15 @@ l’administration ?""",
|
|||
),)
|
||||
|
||||
MyBaseSchema = BaseSchema.copy()
|
||||
INVISIBLE = {'edit': 'invisible', 'view': 'invisible'}
|
||||
MyBaseSchema['title'].widget.visible = INVISIBLE
|
||||
MyBaseSchema['title'].required = False
|
||||
MyBaseSchema['title'].default = u"Avis législatif"
|
||||
AvisLegis_schema = MyBaseSchema.copy() + schema.copy()
|
||||
|
||||
class AvisLegis(BaseContent):
|
||||
class AvisLegis(BaseContent, AvisOdt):
|
||||
'''An "AvisLegis" is a legistic critic of a legal text.'''
|
||||
security = ClassSecurityInfo()
|
||||
__implements__ = (getattr(BaseContent,'__implements__',()),)
|
||||
|
||||
# This name appears in the 'add' box
|
||||
archetype_name = 'AvisLegis'
|
||||
archetype_name = u'Avis légistique'
|
||||
meta_type = 'AvisLegis'
|
||||
portal_type = 'AvisLegis'
|
||||
allowed_content_types = []
|
||||
|
@ -3792,6 +3830,8 @@ class AvisLegis(BaseContent):
|
|||
typeDescription = "AvisLegis"
|
||||
typeDescMsgId = 'description_edit_avis_simplif'
|
||||
|
||||
security.declarePublic('generateOdt')
|
||||
|
||||
actions = (
|
||||
{'action': "string:$object_url/generateOdt",
|
||||
'category': "document_actions",
|
||||
|
|
Binary file not shown.
|
@ -29,6 +29,8 @@ import os, time, os.path
|
|||
import appy.pod.renderer
|
||||
from Products.MasterSelectWidget.MasterSelectWidget import MasterSelectWidget
|
||||
|
||||
from Avis import AvisOdt
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
def slaveFields(action, *slaves):
|
||||
'''Helps to define more smartly the slave fields of a master field
|
||||
|
@ -147,6 +149,44 @@ defaultRecommandationsValues = {
|
|||
|
||||
schema = Schema((
|
||||
|
||||
# Attributs liés au texte en projet ----------------------------------------
|
||||
|
||||
StringField(
|
||||
name='apType',
|
||||
widget=SelectionWidget(
|
||||
label="Type de norme",
|
||||
format="select",
|
||||
label_msgid='Avis_label_apType',
|
||||
i18n_domain='Avis',
|
||||
),
|
||||
enforceVocabulary=True,
|
||||
vocabulary=DisplayList(( ('arreteGouv', u'arrêté du Gouvernement wallon'),
|
||||
('arreteMin', u'arrêté ministériel'),
|
||||
('decret', u'décret') )),
|
||||
required=True
|
||||
),
|
||||
|
||||
StringField(
|
||||
name='apTitle',
|
||||
widget=TextAreaWidget(
|
||||
label=u"Intitulé de la norme",
|
||||
rows=3,
|
||||
label_msgid='Avis_label_apTitle',
|
||||
i18n_domain='Avis',
|
||||
),
|
||||
required=True
|
||||
),
|
||||
|
||||
StringField(
|
||||
name='apDescription',
|
||||
widget=TextAreaWidget(
|
||||
label=u"Contexte",
|
||||
rows=5,
|
||||
label_msgid='Avis_label_apDescription',
|
||||
i18n_domain='Avis',
|
||||
)
|
||||
),
|
||||
|
||||
# Les délais ---------------------------------------------------------------
|
||||
|
||||
StringField(
|
||||
|
@ -743,24 +783,20 @@ schema = Schema((
|
|||
)
|
||||
|
||||
MyBaseSchema = BaseSchema.copy()
|
||||
INVISIBLE = {'edit': 'invisible', 'view': 'invisible'}
|
||||
MyBaseSchema['title'].widget.visible = INVISIBLE
|
||||
MyBaseSchema['title'].required = False
|
||||
MyBaseSchema['title'].default = "Avis simplification"
|
||||
AvisSimplif_schema = MyBaseSchema.copy() + schema.copy()
|
||||
|
||||
class AvisSimplif(BaseContent):
|
||||
class AvisSimplif(BaseContent, AvisOdt):
|
||||
'''An "AvisSimplif" is a simplification-oriented critic of a legal text.'''
|
||||
security = ClassSecurityInfo()
|
||||
__implements__ = (getattr(BaseContent,'__implements__',()),)
|
||||
|
||||
# This name appears in the 'add' box
|
||||
archetype_name = 'AvisSimplif'
|
||||
archetype_name = 'Avis de simplification'
|
||||
meta_type = 'AvisSimplif'
|
||||
portal_type = 'AvisSimplif'
|
||||
allowed_content_types = []
|
||||
filter_content_types = 0
|
||||
global_allow = False
|
||||
global_allow = 1
|
||||
#content_icon = 'Avis.gif'
|
||||
immediate_view = 'base_view'
|
||||
default_view = 'base_view'
|
||||
|
@ -768,6 +804,19 @@ class AvisSimplif(BaseContent):
|
|||
typeDescription = "AvisSimplif"
|
||||
typeDescMsgId = 'description_edit_avis_simplif'
|
||||
|
||||
security.declarePublic('generateOdt')
|
||||
|
||||
actions = (
|
||||
{'action': "string:$object_url/generateOdt",
|
||||
'category': "document_actions",
|
||||
'id': 'asOdt',
|
||||
'name': 'Generer en ODT',
|
||||
'permissions': ("View",),
|
||||
'condition': 'python:1'
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
_at_rename_after_creation = True
|
||||
schema = AvisSimplif_schema
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ def install(self):
|
|||
# Add a tab in portal_actions
|
||||
actions = self.portal_actions.listActions()
|
||||
action_ids = [action.id for action in actions]
|
||||
if not TAB_ID in action_ids:
|
||||
if False and not TAB_ID in action_ids:
|
||||
self.portal_actions.addAction(
|
||||
TAB_ID, 'Avis', 'string:$portal_url/avis', 'member',
|
||||
'View', 'portal_tabs')
|
||||
|
|
|
@ -140,7 +140,7 @@ def install(self, reinstall=False):
|
|||
# enable portal_factory for given types
|
||||
factory_tool = getToolByName(self,'portal_factory')
|
||||
factory_types=[
|
||||
"Avis",
|
||||
"AvisLegis", "AvisSimplif",
|
||||
"AvisConfiguration",
|
||||
"AvisFolder",
|
||||
] + factory_tool.getFactoryTypes().keys()
|
||||
|
|
|
@ -76,7 +76,6 @@ def initialize(context):
|
|||
|
||||
# imports packages and types for registration
|
||||
|
||||
import Avis
|
||||
import AvisSimplif
|
||||
import AvisLegis
|
||||
import AvisConfiguration
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
|
||||
<metal:block define-slot="widgets">
|
||||
|
||||
<!-- Main fields -->
|
||||
<span metal:use-macro="python:here.widget('title', mode='edit')" />
|
||||
<span metal:use-macro="python:here.widget('apType', mode='edit')" />
|
||||
<span metal:use-macro="python:here.widget('apTitle', mode='edit')" />
|
||||
<span metal:use-macro="python:here.widget('apDescription', mode='edit')" />
|
||||
|
||||
<p>L’avis émis ci-dessous vise des recommandations relatives aux règles de
|
||||
technique législative.</p>
|
||||
<fieldset style="border-width: 4px;"><legend>Questions préalables</legend>
|
||||
|
|
|
@ -21,12 +21,10 @@
|
|||
<metal:block define-slot="widgets">
|
||||
|
||||
<!-- Main fields -->
|
||||
<!--
|
||||
<span metal:use-macro="python:here.widget('title', mode='edit')" />
|
||||
<span metal:use-macro="python:here.widget('apType', mode='edit')" />
|
||||
<span metal:use-macro="python:here.widget('apTitle', mode='edit')" />
|
||||
<span metal:use-macro="python:here.widget('apDescription', mode='edit')" />
|
||||
-->
|
||||
|
||||
<fieldset style="border-width: 4px;"><legend><b>Les délais</b></legend>
|
||||
<span metal:use-macro="python:here.widget('delai', mode='edit')" />
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<!-- Texte en projet -->
|
||||
|
||||
<!--
|
||||
<fieldset>
|
||||
<legend>Texte en projet</legend>
|
||||
<div tal:define="f python:here.getField('apTitle')">
|
||||
|
@ -21,7 +20,6 @@
|
|||
<b tal:content="f/widget/label"></b> : <span tal:content="python: f.vocabulary.getValue(here.getApType())"></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
-->
|
||||
|
||||
<h2>Mesures concrètes de simplification administrative</h2>
|
||||
|
||||
|
|
Reference in New Issue