コード例 #1
0
    def validate(self, value):
        # Perform the standard validation first
        super(ValidateEUpReleaseLinkUniqueness, self).validate(value)

        if value is not None:
            if IEUpReleaseLink.providedBy(self.context):
                # The release number is the same as the previous value stored
                # in the object
                if self.context.releasenumber == value:
                    return None

            catalog = api.portal.get_tool(name='portal_catalog')
            # Differentiate between possible contexts (on creation or editing)
            # on creation the context is the container
            # on editing the context is already the object
            if IEUpReleaseLink.providedBy(self.context):
                query = '/'.join(self.context.aq_parent.getPhysicalPath())
            else:
                query = '/'.join(self.context.getPhysicalPath())

            result = catalog({
                'path': {'query': query, 'depth': 1},
                'portal_type': ['tdf.extensionuploadcenter.euprelease',
                                'tdf.extensionuploadcenter.eupreleaselink'],
                'release_number': value})

            if len(result) > 0:
                raise Invalid(_(u"The release number is already in use. Please choose another one."))
コード例 #2
0
    def validate(self, value):
        # Perform the standard validation first
        super(ValidateEUpProjectUniqueness, self).validate(value)

        if value is not None:
            catalog = api.portal.get_tool(name='portal_catalog')
            results = catalog({'Title': value,
                               'object_provides': IEUpProject.__identifier__})

            contextUUID = IUUID(self.context, None)
            for result in results:
                if result.UID != contextUUID:
                    raise Invalid(_(u"The project title is already in use"))
コード例 #3
0
    def validate(self, value):
        # Perform the standard validation first
        super(ValidateEUpProjectUniqueness, self).validate(value)
        if value is not None:
            catalog = api.portal.get_tool(name='portal_catalog')
            results = catalog({
                'Title': quote_chars(value),
                'object_provides': IEUpProject.__identifier__
            })

            contextUUID = IUUID(self.context, None)
            for result in results:
                if result.UID != contextUUID:
                    raise Invalid(_(u"The project title is already in use."))
コード例 #4
0
    def validate(self, value):
        # Perform the standard validation first
        super(ValidateEUpReleaseUniqueness, self).validate(value)

        if value is not None:
            if IEUpRelease.providedBy(self.context):
                # The release number is the same as the previous value stored
                # in the object
                if self.context.releasenumber == value:
                    return None

            catalog = api.portal.get_tool(name='portal_catalog')
            # Differentiate between possible contexts (on creation or editing)
            # on creation the context is the container
            # on editing the context is already the object
            if IEUpRelease.providedBy(self.context):
                query = '/'.join(self.context.aq_parent.getPhysicalPath())
            else:
                query = '/'.join(self.context.getPhysicalPath())

            result = catalog({
                'path': {
                    'query': query,
                    'depth': 1
                },
                'portal_type': [
                    'tdf.extensionuploadcenter.euprelease',
                    'tdf.extensionuploadcenter.eupreleaselink'
                ],
                'release_number':
                value
            })

            if len(result) > 0:
                raise Invalid(
                    _(u"The release number is already in use. Please choose another one."
                      ))
コード例 #5
0
class IEUpRelease(model.Schema):
    form.mode(projecttitle='hidden')
    projecttitle = schema.TextLine(
        title=_(u"The Computed Project Title"),
        description=_(
            u"The release title will be computed from the parent project title."
        ),
        defaultFactory=getContainerTitle)

    releasenumber = schema.TextLine(
        title=_(u"Release Number"),
        description=_(u"Release Number (up to twelf chars)"),
        default=_(u"1.0"),
        max_length=12,
    )

    description = schema.Text(title=_(u"Release Summary"), )

    form.primary('details')
    details = RichText(title=_(u"Full Release Description"), required=False)

    form.primary('changelog')
    changelog = RichText(
        title=_(u"Changelog"),
        description=_(
            u"A detailed log of what has changed since the previous release."),
        required=False,
    )

    form.widget(licenses_choice=CheckBoxFieldWidget)
    licenses_choice = schema.List(
        title=_(u'License of the uploaded file'),
        description=_(
            u"Please mark one or more licenses you publish your release."),
        value_type=schema.Choice(source=vocabAvailLicenses),
        required=True,
    )

    form.widget(compatibility_choice=CheckBoxFieldWidget)
    compatibility_choice = schema.List(
        title=_(u"Compatible with versions of LibreOffice"),
        description=
        _(u"Please mark one or more program versions with which this release is compatible with."
          ),
        value_type=schema.Choice(source=vocabAvailVersions),
        required=True,
        default=[])

    form.mode(title_declaration_legal='display')
    title_declaration_legal = schema.TextLine(
        title=_(u""), required=False, defaultFactory=legal_declaration_title)

    form.mode(declaration_legal='display')
    declaration_legal = schema.Text(title=_(u""),
                                    required=False,
                                    defaultFactory=legal_declaration_text)

    accept_legal_declaration = schema.Bool(
        title=_(u"Accept the above legal disclaimer"),
        description=_(
            u"Please declare that you accept the above legal disclaimer."),
        required=True)

    contact_address2 = schema.TextLine(
        title=_(u"Contact email-address"),
        description=_(u"Contact email-address for the project."),
        required=False,
        defaultFactory=contactinfoDefault)

    source_code_inside = schema.Choice(
        title=_(u"Is the source code inside the extension?"),
        vocabulary=yesnochoice,
        required=True)

    link_to_source = schema.URI(
        title=_(u"Please fill in the Link (URL) to the Source Code."),
        required=False)

    file = NamedBlobFile(
        title=_(u"The first file you want to upload."),
        description=_(u"Please upload your file."),
        required=True,
        constraint=validatefileextension,
    )

    form.widget(platform_choice=CheckBoxFieldWidget)
    platform_choice = schema.List(
        title=_(u"First uploaded file is compatible with the Platform(s)"),
        description=
        _(u"Please mark one or more platforms with which the uploaded file is compatible."
          ),
        value_type=schema.Choice(source=vocabAvailPlatforms),
        required=True,
    )

    form.mode(information_further_file_uploads='display')
    model.primary('information_further_file_uploads')
    information_further_file_uploads = RichText(
        title=_(u"Further File Uploads for this Release"),
        description=_(u"If you want to upload more files for this release, "
                      u"e.g. because there are files for other operating "
                      u"systems, you'll find the upload fields on the "
                      u"register 'File Upload 1' and 'File Upload 2'."),
        required=False)

    form.fieldset('fileset1',
                  label=u"File Upload 1",
                  fields=[
                      'filetitlefield1', 'file1', 'platform_choice1',
                      'filetitlefield2', 'file2', 'platform_choice2',
                      'filetitlefield3', 'file3', 'platform_choice3'
                  ])

    form.mode(filetitlefield1='display')
    filetitlefield1 = schema.TextLine(title=_(u"Second Release File"), )

    file1 = NamedBlobFile(
        title=_(u"The second file you want to upload (this is optional)"),
        description=_(u"Please upload your file."),
        required=False,
        constraint=validatefileextension,
    )

    form.widget(platform_choice1=CheckBoxFieldWidget)
    platform_choice1 = schema.List(
        title=_(u"Second uploaded file is compatible with the Platform(s)"),
        description=
        _(u"Please mark one or more platforms with which the uploaded file is compatible."
          ),
        value_type=schema.Choice(source=vocabAvailPlatforms),
        required=False,
    )

    form.mode(filetitlefield2='display')
    filetitlefield2 = schema.TextLine(title=_(u"Third Release File"), )

    file2 = NamedBlobFile(
        title=_(u"The third file you want to upload (this is optional)"),
        description=_(u"Please upload your file."),
        required=False,
        constraint=validatefileextension,
    )

    form.widget(platform_choice2=CheckBoxFieldWidget)
    platform_choice2 = schema.List(
        title=_(u"Third uploaded file is compatible with the Platform(s))"),
        description=
        _(u"Please mark one or more platforms with which the uploaded file is compatible."
          ),
        value_type=schema.Choice(source=vocabAvailPlatforms),
        required=False,
    )

    form.mode(filetitlefield3='display')
    filetitlefield3 = schema.TextLine(title=_(u"Fourth Release File"), )

    file3 = NamedBlobFile(
        title=_(u"The fourth file you want to upload (this is optional)"),
        description=_(u"Please upload your file."),
        required=False,
        constraint=validatefileextension,
    )

    form.widget(platform_choice3=CheckBoxFieldWidget)
    platform_choice3 = schema.List(
        title=_(u"Fourth uploaded file is compatible with the Platform(s)"),
        description=
        _(u"Please mark one or more platforms with which the uploaded file is compatible."
          ),
        value_type=schema.Choice(source=vocabAvailPlatforms),
        required=False,
    )

    form.fieldset('fileset2',
                  label=u"File Upload 2",
                  fields=[
                      'filetitlefield4', 'file4', 'platform_choice4',
                      'filetitlefield5', 'file5', 'platform_choice5'
                  ])

    form.mode(filetitlefield4='display')
    filetitlefield4 = schema.TextLine(title=_(u"Fifth Release File"), )

    file4 = NamedBlobFile(
        title=_(u"The fifth file you want to upload (this is optional)"),
        description=_(u"Please upload your file."),
        required=False,
        constraint=validatefileextension,
    )

    form.widget(platform_choice4=CheckBoxFieldWidget)
    platform_choice4 = schema.List(
        title=_(u"Fifth uploaded file is compatible with the Platform(s)"),
        description=
        _(u"Please mark one or more platforms with which the uploaded file is compatible."
          ),
        value_type=schema.Choice(source=vocabAvailPlatforms),
        required=False,
    )

    form.mode(filetitlefield5='display')
    filetitlefield5 = schema.TextLine(title=_(u"Sixth Release File"), )

    file5 = NamedBlobFile(
        title=_(u"The sixth file you want to upload (this is optional)"),
        description=_(u"Please upload your file."),
        required=False,
        constraint=validatefileextension,
    )

    form.widget(platform_choice5=CheckBoxFieldWidget)
    platform_choice5 = schema.List(
        title=_(u"Sixth uploaded file is compatible with the Platform(s)"),
        description=
        _(u"Please mark one or more platforms with which the uploaded file is compatible."
          ),
        value_type=schema.Choice(source=vocabAvailPlatforms),
        required=False,
    )

    @invariant
    def licensenotchoosen(value):
        if not value.licenses_choice:
            raise Invalid(_(u"Please choose a license for your release."))

    @invariant
    def compatibilitynotchoosen(data):
        if not data.compatibility_choice:
            raise Invalid(
                _(u"Please choose one or more compatible product versions for your release."
                  ))

    @invariant
    def legaldeclarationaccepted(data):
        if data.accept_legal_declaration is not True:
            raise AcceptLegalDeclaration(
                _(u"Please accept the Legal Declaration about your Release and your Uploaded File"
                  ))

    @invariant
    def testingvalue(data):
        if data.source_code_inside is not 1 and data.link_to_source is None:
            raise Invalid(
                _(u"You answered the question, whether the source code is inside your extension with no "
                  u"(default answer). If this is the correct answer, please fill in the Link (URL) "
                  u"to the Source Code."))

    @invariant
    def noOSChosen(data):
        if data.file is not None and data.platform_choice == []:
            raise Invalid(
                _(u"Please choose a compatible platform for the uploaded file."
                  ))
コード例 #6
0
    """ pick up the list of platforms from parent """

    platforms_list = getattr(context.__parent__, 'available_platforms', [])
    terms = []
    for value in platforms_list:
        terms.append(
            SimpleTerm(value,
                       token=value.encode('unicode_escape'),
                       title=value))
    return SimpleVocabulary(terms)


directlyProvides(vocabAvailPlatforms, IContextSourceBinder)

yesnochoice = SimpleVocabulary([
    SimpleTerm(value=0, title=_(u'No')),
    SimpleTerm(value=1, title=_(u'Yes')),
])


@provider(IContextAwareDefaultFactory)
def getContainerTitle(self):
    return (self.aq_inner.title)


@provider(IContextAwareDefaultFactory)
def contactinfoDefault(context):
    return context.contactAddress


@provider(IContextAwareDefaultFactory)
コード例 #7
0
class AcceptLegalDeclaration(Invalid):
    __doc__ = _(u"It is necessary that you accept the Legal Declaration")
コード例 #8
0
class MissingCategory(Invalid):
    __doc__ = _(u"You have not chosen a category for the project.")
コード例 #9
0
class IEUpProject(model.Schema):

    dexteritytextindexer.searchable('title')
    title = schema.TextLine(
        title=_(u"Title"),
        description=_(u"Project Title - minimum 5 and maximum 50 characters"),
        min_length=5,
        max_length=50)

    dexteritytextindexer.searchable('description')
    description = schema.Text(title=_(u"Project Summary"), )

    dexteritytextindexer.searchable('details')
    form.primary('details')
    details = RichText(title=_(u"Full Project Description"), required=False)

    dexteritytextindexer.searchable('category_choice')
    form.widget(category_choice=CheckBoxFieldWidget)
    category_choice = schema.List(
        title=_(u"Choose your categories"),
        description=
        _(u"Please select the appropriate categories (one or more) for your project."
          ),
        value_type=schema.Choice(source=vocabCategories),
        constraint=isNotEmptyCategory,
        required=True)

    contactAddress = schema.TextLine(
        title=_(u"Contact email-address"),
        description=_(u"Contact email-address for the project."),
        constraint=validateEmail)

    homepage = schema.URI(
        title=_(u"Homepage"),
        description=
        _(u"If the project has an external home page, enter its URL (example: 'http://www.mysite.org')."
          ),
        required=False)

    documentation_link = schema.URI(
        title=_(u"URL of documentation repository "),
        description=_(u"If the project has externally hosted "
                      u"documentation, enter its URL "
                      u"(example: 'http://www.mysite.org')."),
        required=False)

    documentation_file = NamedBlobFile(
        title=_(u"Dokumentation File"),
        description=
        _(u"If you have a Documentation in the file format 'PDF' or 'ODT' you could add it here."
          ),
        required=False,
        constraint=validatedocfileextension)

    project_logo = NamedBlobImage(
        title=_(u"Logo"),
        description=
        _(u"Add a logo for the project (or organization/company) by clicking the 'Browse' button."
          u"You could provide an image of the file format 'png', 'gif' or 'jpg'."
          ),
        required=False,
        constraint=validateImageextension)

    screenshot = NamedBlobImage(
        title=_(u"Screenshot of the Extension"),
        description=_(
            u"Add a screenshot by clicking the 'Browse' button. You could provide an image of the file "
            u"format 'png', 'gif' or 'jpg'."),
        required=False,
        constraint=validateImageextension)

    @invariant
    def missingScreenshotOrLogo(data):
        if not data.screenshot and not data.project_logo:
            raise ProvideScreenshotLogo(
                _(u'Please add a screenshot or a logo to your project page. You will find the '
                  u'appropriate fields below on this page.'))
コード例 #10
0
 def legaldeclarationaccepted(data):
     if data.accept_legal_declaration is not True:
         raise AcceptLegalDeclaration(
             _(u"Please accept the Legal Declaration about your Release and your Uploaded File"
               ))
コード例 #11
0
 def licensenotchoosen(value):
     if not value.licenses_choice:
         raise Invalid(_(u"Please choose a license for your release."))
コード例 #12
0
 def missingScreenshotOrLogo(data):
     if not data.screenshot and not data.project_logo:
         raise ProvideScreenshotLogo(
             _(u'Please add a screenshot or a logo to your project page. You will find the '
               u'appropriate fields below on this page.'))
コード例 #13
0
 def noOSChosen(data):
     if data.file is not None and data.platform_choice == []:
         raise Invalid(
             _(u"Please choose a compatible platform for the uploaded file."
               ))
コード例 #14
0
 def noOSChosen(data):
     if data.link_to_file is not None and data.platform_choice == []:
         raise Invalid(_(u"Please choose a compatible platform for the linked file."))
コード例 #15
0
def validateEmail(value):
    if not checkEmail(value):
        raise Invalid(_(u"Invalid email address"))
    return True
コード例 #16
0
 def testingvalue(data):
     if data.source_code_inside is not 1 and data.link_to_source is None:
         raise Invalid(_(u"Please fill in the Link (URL) to the Source Code."))
コード例 #17
0
 def legaldeclarationaccepted(data):
     if data.accept_legal_declaration is not True:
         raise AcceptLegalDeclaration(_(u"Please accept the Legal Declaration about "
                                        U"your Release and your linked File"))
コード例 #18
0
 def compatibilitynotchoosen(data):
     if not data.compatibility_choice:
         raise Invalid(_(u"Please choose one or more compatible product versions for your release"))
コード例 #19
0
 def licensenotchoosen(value):
     if not value.licenses_choice:
         raise Invalid(_(u"Please choose a license for your release."))
コード例 #20
0
 def missingScreenshotOrLogo(data):
     if not data.screenshot and not data.project_logo:
         raise ProvideScreenshotLogo(_(u'Please add a Screenshot or a Logo to your project page'))
コード例 #21
0
 def compatibilitynotchoosen(data):
     if not data.compatibility_choice:
         raise Invalid(
             _(u"Please choose one or more compatible product versions for your release."
               ))
コード例 #22
0
class ProvideScreenshotLogo(Invalid):
    __doc__ = _(
        u"Please add a screenshot or a logo to your project. You find the appropriate fields below "
        u"on this page.")
コード例 #23
0
 def testingvalue(data):
     if data.source_code_inside is not 1 and data.link_to_source is None:
         raise Invalid(
             _(u"You answered the question, whether the source code is inside your extension with no "
               u"(default answer). If this is the correct answer, please fill in the Link (URL) "
               u"to the Source Code."))
コード例 #24
0

def vocabAvailPlatforms(context):
    """ pick up the list of platforms from parent """

    platforms_list = getattr(context.__parent__, 'available_platforms', [])
    terms = []
    for value in platforms_list:
        terms.append(SimpleTerm(value, token=value.encode('unicode_escape'), title=value))
    return SimpleVocabulary(terms)


directlyProvides(vocabAvailPlatforms, IContextSourceBinder)

yesnochoice = SimpleVocabulary(
    [SimpleTerm(value=0, title=_(u'No')),
     SimpleTerm(value=1, title=_(u'Yes')), ]
)


@provider(IContextAwareDefaultFactory)
def getContainerTitle(self):
    return (self.aq_inner.title)


@provider(IContextAwareDefaultFactory)
def contactinfoDefault(context):
    return context.contactAddress


@provider(IContextAwareDefaultFactory)
コード例 #25
0
def validateEmail(value):
    if not checkEmail(value):
        raise Invalid(_(u"Invalid email address"))
    return True
コード例 #26
0
class IEUpCenter(model.Schema):
    """ An Extension Upload Center for LibreOffice extensions.
    """

    title = schema.TextLine(title=_(u"Name of the Extensions Center"), )

    description = schema.Text(
        description=_(u"Description of the Extensions Center"), )

    product_description = schema.Text(
        description=_(u"Description of the features of extensions"))

    product_title = schema.TextLine(
        title=_(u"Extension Product Name"),
        description=
        _(u"Name of the Extension product, e.g. only Extensions or LibreOffice Extensions"
          ),
    )

    form.fieldset('categories_et_all',
                  label=u"Categories et all",
                  fields=[
                      'available_category', 'available_licenses',
                      'available_versions', 'available_platforms'
                  ])

    available_category = schema.List(title=_(u"Available Categories"),
                                     default=[
                                         'All modules',
                                         'Dictionary',
                                         'Clipart',
                                         'Macro',
                                         'Template Extension',
                                         'Gallery Contents',
                                         'Language Tools',
                                         'Writer Extension',
                                         'Calc Extension',
                                         'Impress Extension',
                                         'Draw Extension',
                                         'Base Extension',
                                         'Math Extension',
                                         'Extension Building',
                                     ],
                                     value_type=schema.TextLine())

    available_licenses = schema.List(
        title=_(u"Available Licenses"),
        default=[
            'GNU-GPL-v2 (GNU General Public License Version 2)',
            'GNU-GPL-v3 (General Public License Version 3)',
            'LGPL-v2.1 (GNU Lesser General Public License Version 2.1)',
            'LGPL-v3+ (GNU Lesser General Public License Version 3 and later)',
            'BSD (BSD License (revised))',
            'MPL-v1.1 (Mozilla Public License Version 1.1)',
            'MPL-v2.0+ (Mozilla Public License Version 2.0 or later)',
            'CC-by-sa-v3 (Creative Commons Attribution-ShareAlike 3.0)',
            'CC-BY-SA-v4 (Creative Commons Attribution-ShareAlike 4.0 International)',
            'AL-v2 (Apache License Version 2.0)', 'Public Domain',
            'OSI (Other OSI Approved)'
        ],
        value_type=schema.TextLine())

    available_versions = schema.List(
        title=_(u"Available Versions"),
        default=[
            'LibreOffice 3.3', 'LibreOffice 3.4', 'LibreOffice 3.5',
            'LibreOffice 3.6', 'LibreOffice 4.0', 'LibreOffice 4.1',
            'LibreOffice 4.2', 'LibreOffice 4.3', 'LibreOffice 4.4',
            'LibreOffice 5.0', 'LibreOffice 5.1', 'LibreOffice 5.2',
            'LibreOffice 5.3', 'LibreOffice 5.4', 'LibreOffice 6.0',
            'LibreOffice 6.1'
        ],
        value_type=schema.TextLine())

    available_platforms = schema.List(title=_(u"Available Platforms"),
                                      default=[
                                          'All platforms', 'Linux',
                                          'Linux-x64', 'Mac OS X', 'Windows',
                                          'BSD', 'UNIX (other)'
                                      ],
                                      value_type=schema.TextLine())

    form.fieldset('instructions',
                  label=u'Instructions',
                  fields=[
                      'install_instructions',
                      'reporting_bugs',
                  ])

    form.primary('install_instructions')
    install_instructions = RichText(
        title=_(u"Extension Installation Instructions"),
        description=_(u"Please fill in the install instructions"),
        required=False)

    form.primary('reporting_bugs')
    reporting_bugs = RichText(title=_(u"Instruction how to report Bugs"),
                              required=False)

    form.fieldset('disclaimer',
                  label=u'Legal Disclaimer',
                  fields=[
                      'title_legaldisclaimer', 'legal_disclaimer',
                      'title_legaldownloaddisclaimer',
                      'legal_downloaddisclaimer'
                  ])

    title_legaldisclaimer = schema.TextLine(
        title=_(u"Title for Legal Disclaimer and Limitations"),
        default=_(u"Legal Disclaimer and Limitations"),
        required=False)

    legal_disclaimer = schema.Text(
        title=_(u"Text of the Legal Disclaimer and Limitations"),
        description=_(u"Enter the text of the legal disclaimer and "
                      u"limitations that should be displayed to the "
                      u"project creator and should be accepted by "
                      u"the owner of the project."),
        default=_(u"Fill in the legal disclaimer, that had to be "
                  u"accepted by the project owner."),
        required=False)

    title_legaldownloaddisclaimer = schema.TextLine(
        title=_(
            u"Title of the Legal Disclaimer and Limitations for Downloads"),
        default=_(u"Legal Disclaimer and Limitations for Downloads"),
        required=False)

    form.primary('legal_downloaddisclaimer')
    legal_downloaddisclaimer = RichText(
        title=_(u"Text of the Legal Disclaimer and Limitations for Downlaods"),
        description=_(u"Enter any legal disclaimer and limitations for "
                      u"downloads that should appear on each page for "
                      u"dowloadable files."),
        default=_(u"Fill in the text for the legal download disclaimer."),
        required=False)

    form.primary('information_oldversions')
    information_oldversions = RichText(
        title=_(u"Information About Search For Old LibreOffice Versions"),
        description=_(u"Enter an information about the search for older "
                      u"versions of LibreOffice, if they are not on the "
                      u"versions list (compatibility) anymore."),
        required=False)

    form.fieldset('contactadresses',
                  label=u'Special Email Adresses',
                  fields=['releaseAllert', 'contactForCenter'])

    releaseAllert = schema.ASCIILine(
        title=_(u"EMail address for the messages about new releases"),
        description=
        _(u"Enter an email address to which information about a new release should be send."
          ),
        required=False)

    contactForCenter = schema.ASCIILine(
        title=
        _(u"EMail address for communication with the extension center manager and reviewer"
          ),
        description=
        _(u"Enter an email address for the communication with extension center manager and reviewer"
          ),
        default='*****@*****.**',
        constraint=validateEmail)