Good morning everyone,
I am in the process of preparing a classic Plone addon to function within the Volto CMS. However, I am running into an issue with setting the Title and Description. Whenever I try to submit new content, I get the following error in the python console:
2022-04-18 10:42:46,708 ERROR [Zope.SiteErrorLog:35][waitress-0] ValueError: http://localhost:3000/admissions-new/POST_application_json_
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 371, in publish_module
Module ZPublisher.WSGIPublisher, line 274, in publish
Module ZPublisher.mapply, line 85, in mapply
Module ZPublisher.WSGIPublisher, line 63, in call_object
Module plone.rest.service, line 22, in __call__
Module plone.restapi.services, line 19, in render
Module plone.restapi.services.content.add, line 55, in reply
Module plone.restapi.services.content.utils, line 57, in create
Module plone.dexterity.factory, line 44, in __call__
ValueError: Error whilst constructing content for admissions_docs using class yc.documents.content.admissions_docs.AdmissionsDocs: setTitle() takes 1 positional argument but 2 were given
Here is the python code:
# -*- coding: utf-8 -*-
from plone import api
from plone.app.z3cform.widget import SelectFieldWidget
from plone.autoform import directives
from plone.dexterity.content import Item
from plone.namedfile.field import NamedBlobFile
from plone.supermodel import model
from yc.documents import _
from zope import schema
from zope.interface import implementer
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary
from Products.CMFPlone.utils import safe_hasattr
def compute_employeeID():
user = api.user.get_current()
property = user.getProperty('employeeID')
return str(property)
def compute_first_name():
user = api.user.get_current()
property = user.getProperty('first_name')
return str(property)
def compute_last_name():
user = api.user.get_current()
property = user.getProperty('last_name')
return str(property)
def compute_email():
user = api.user.get_current()
property = user.getProperty('email')
return str(property)
attachmentTypeVocabulary = SimpleVocabulary(
[
SimpleTerm(value=u'CUNY Residency Form', title=_(u'CUNY Residency Form')),
SimpleTerm(value=u'DD214 Card', title=_(u'DD214 Card')),
SimpleTerm(value=u'Graduate Application', title=_(u'Graduate Application')),
SimpleTerm(value=u'High School and College Transcripts', title=_(u'High School and College Transcripts')),
SimpleTerm(value=u'High School Diploma', title=_(u'High School Diploma')),
SimpleTerm(value=u'Non-Degree Application', title=_(u'Non-Degree Application')),
SimpleTerm(value=u'Permanent ResidencyCard, US Passport, Naturalization, Copy of I-551',
title=_(u'Permanent ResidencyCard, US Passport, Naturalization, Copy of I-551')),
SimpleTerm(value=u'Proof of Name Change, DOB', title=_(u'Proof of Name Change, DOB')),
SimpleTerm(value=u'SAT and ACT Scores', title=_(u'SAT and ACT Scores')),
SimpleTerm(value=u'Social Security Card', title=_(u'Social Security Card')),
]
)
yearVocabulary = SimpleVocabulary(
[
SimpleTerm(value=u'Winter 2021', title=_(u'Winter 2021')),
SimpleTerm(value=u'Spring 2021', title=_(u'Spring 2021')),
SimpleTerm(value=u'Summer 2021', title=_(u'Summer 2021')),
SimpleTerm(value=u'Fall 2021', title=_(u'Fall 2021')),
SimpleTerm(value=u'Winter 2022', title=_(u'Winter 2022')),
SimpleTerm(value=u'Spring 2022', title=_(u'Spring 2022')),
SimpleTerm(value=u'Summer 2022', title=_(u'Summer 2022')),
SimpleTerm(value=u'Fall 2022', title=_(u'Fall 2022')),
]
)
class IAdmissionsDocs(model.Schema):
""" Marker interface and Dexterity Python Schema for AdmissionsDocs
"""
academic_year = schema.Choice(
title=_(u'Semester'),
required=True,
vocabulary=yearVocabulary,
)
attachment_file = NamedBlobFile(
title=_(u'Attachments 1'),
description=_(u' '),
required=True,
)
attachment_type = schema.Choice(
title=_(u'Attachments 1 Type'),
description=_(u'Identify document'),
required=True,
vocabulary=attachmentTypeVocabulary,
)
attachment_file1 = NamedBlobFile(
title=_(u'Attachments 2'),
description=_(u' '),
required=False,
)
attachment_type1 = schema.Choice(
title=_(u'Attachments 2 Type'),
description=_(u'Identify document'),
required=False,
vocabulary=attachmentTypeVocabulary,
)
attachment_file2 = NamedBlobFile(
title=_(u'Attachments 3'),
description=_(u' '),
required=False,
)
attachment_type2 = schema.Choice(
title=_(u'Attachments 3 Type'),
description=_(u'Identify document'),
required=False,
vocabulary=attachmentTypeVocabulary,
)
attachment_file3 = NamedBlobFile(
title=_(u'Attachments 4'),
description=_(u' '),
required=False,
)
attachment_type3 = schema.Choice(
title=_(u'Attachments 4 Type'),
description=_(u'Identify document'),
required=False,
vocabulary=attachmentTypeVocabulary,
)
attachment_file4 = NamedBlobFile(
title=_(u'Attachments 5'),
description=_(u' '),
required=False,
)
attachment_type4 = schema.Choice(
title=_(u'Attachments 5 Type'),
description=_(u'Identify document'),
required=False,
vocabulary=attachmentTypeVocabulary,
)
directives.widget('attachment_type', SelectFieldWidget)
directives.widget('attachment_type1', SelectFieldWidget)
directives.widget('attachment_type2', SelectFieldWidget)
directives.widget('attachment_type3', SelectFieldWidget)
directives.widget('attachment_type4', SelectFieldWidget)
directives.mode(employeeID='hidden')
employeeID = schema.TextLine(
title=_(u'employeeID'),
required=False,
defaultFactory=compute_employeeID,
)
directives.mode(first_name='hidden')
first_name = schema.TextLine(
title=_(u'first_name'),
required=False,
defaultFactory=compute_first_name,
)
directives.mode(last_name='hidden')
last_name = schema.TextLine(
title=_(u'last_name'),
required=False,
defaultFactory=compute_last_name,
)
@implementer(IAdmissionsDocs)
class AdmissionsDocs(Item):
"""
"""
def setTitle(self):
self.setTitle = self.computeTitle()
def Title(self):
return self.computeTitle()
def computeTitle(self):
return str(self.last_name) + ', ' + str(self.first_name) + ' - ' + str(self.employeeID)
def setDescription(self):
self.setDescription = self.computeDescription()
def Description(self):
return self.computeDescription()
def computeDescription(self):
return str(self.employeeID)
I am currently running Plone 5.2.6 (backend) with Volto 15.4.1 (frontend).
What should I do to ensure that this addon is compatible in Volto? Would I need to adjust the python code at all? Or is it mostly a frontend issue in Volto where I must change the code there?
I thank you kindly.
Sincerely,
rbrown12