Skip to content

Commit

Permalink
Add default method for title
Browse files Browse the repository at this point in the history
  • Loading branch information
adriana-rv committed Feb 8, 2018
1 parent 706bf22 commit 5bd1b41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/collective/judgment/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def order_items(self):
items['report'] = None
items['plan'] = None
items['letter'] = None
items['pdf'] = None
others = []

for item in self.context.items():
Expand All @@ -45,6 +46,8 @@ def order_items(self):
items['report'] = item[1]
elif itemportal == 'Reasoned Letter':
items['letter'] = item[1]
elif itemportal == 'Pdf File':
items['pdf'] = item[1]
else:
others.append(item[1])

Expand All @@ -55,14 +58,15 @@ def iddictToType(self, key):
'cv': 'Curriculum Vitae',
'plan': 'Activities Plan',
'report': 'Activities Report',
'letter': 'Reasoned Letter'
'letter': 'Reasoned Letter',
'pdf': 'Pdf File'
}
return iddict.get(key, '')

def editurl(self, key):
nametype = self.iddictToType(key)
if nametype:
return '++add++' + nametype
return '++add++' + nametype + '?title=foopdf'

return ''

Expand Down
12 changes: 11 additions & 1 deletion src/collective/judgment/content/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@

from collective.judgment.validators import isValidFileType
from plone.autoform import directives
from zope.interface import provider
from zope.schema.interfaces import IContextAwareDefaultFactory



@provider(IContextAwareDefaultFactory)
def request_title(context):
return context.REQUEST.form.get('title', '')


class IPdfFile(model.Schema):
""" Marker interfce and Dexterity Python Schema for Promotion
"""
# directives.omitted('title')
title = schema.TextLine(
title=_(u'Title'),
# description=u"",
required=False
required=False,
defaultFactory=request_title,
)

description = schema.Text(
Expand Down

0 comments on commit 5bd1b41

Please sign in to comment.