Skip to content

Commit

Permalink
Add widgets, translation changes and configure view params for folder…
Browse files Browse the repository at this point in the history
… names
  • Loading branch information
r-ivkos committed May 6, 2024
1 parent dcd6ca3 commit 86afd3b
Show file tree
Hide file tree
Showing 26 changed files with 744 additions and 327 deletions.
37 changes: 30 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ module.exports = function (grunt) {
css: {
src: ['stylesheets/theme.css'],
dest: 'stylesheets/theme-concat.css',
},
js: {
src: ['js/main/*.js'],
dest: 'js/theme-concat.js',
}
},
cssmin: {
css : {
src : ["stylesheets/theme-concat.css"],
dest : "stylesheets/theme-patents.min.css",
css: {
src: ["stylesheets/theme-concat.css"],
dest: "stylesheets/theme-patents.min.css",
}
},
watch: {
Expand All @@ -33,17 +37,36 @@ module.exports = function (grunt) {
],
tasks: ['compass:css', 'concat:css', 'cssmin:css']
},
js: {
// files: [
// 'js/main/*'
// ],
// tasks: ['concat:js', 'uglify:mainjs']
files: [
'js/widgets/*'
],
tasks: ['uglify:js']
},

},
uglify: {
js: {
files: {}
}
files: {
'js/widget-maxlengthtext.min.js': 'js/widgets/maxlengthtext.js',
}
},
// mainjs: {
// files: {
// 'js/theme-patents.min.js': 'js/theme-concat.js'
// }
// }

},
browserSync: {
plone: {
bsFiles: {
src : [
'stylesheets/*.css'
src: [
'stylesheets/*.css'
]
},
options: {
Expand Down
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ Crea la estructura de patentes en la página.

Parámetros:
- ``recreate_subjects`` [bool]: Si se activa, se recrean las etiquetas de las ofertas tecnológicas.
- ``patents_folder`` [string]: Nombre de la carpeta que contendrá la carpeta de ofertas tecnológicas.
- ``techoffer_folder`` [string]: Nombre de la carpeta que contendrá todas las ofertas tecnológicas, el formularió de creación de una oferta y la coleccion de ofertas en estado borrador.

Funconamiento:
- Se crea la carpeta ``patents``
Expand All @@ -123,4 +125,6 @@ Funconamiento:
y, al enviar, crea una nueva oferta dentro de la carpeta ``patents/ofreta-tecnologica``
- Se crea la colección ``patents/ofreta-tecnologica/technological-offers-to-review``
- Esta colección recopila todas las ofertas en estado "Borrador"


Ejemplo:
``localhost:8080/Plone/configure_techoffer?recreate_subjects=True&patents_folder=patents&techoffer_folder=oferta-tecnologica``
18 changes: 12 additions & 6 deletions src/genweb6/patents/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def __call__(self):
recreate_subjects = self.request.form.get('recreate_subjects', '')
recreate_subjects = recreate_subjects and recreate_subjects.lower() == 'true'

patents_folder = self.request.form.get('patents_folder', 'patents')
patents_folder = patents_folder.strip("/")

techoffer_folder = self.request.form.get('techoffer_folder', 'nova-oferta-tecnologica')
techoffer_folder = techoffer_folder.strip("/")

qi = get_installer(self.context)

required_products = [
Expand All @@ -129,25 +135,25 @@ def __call__(self):
with open(xml_config_path / 'ActionModel.xml', 'r') as f:
actions_model = f.read()

patents = api.content.get('/ca/patents')
patents = api.content.get("/ca/" + patents_folder)
logger.info("Getting patents folder")
if not patents:
logger.info("Patents folder not found, creating it at /ca/patents")
logger.info(f"Patents folder not found, creating it at /ca/{patents_folder}")
patents = api.content.create(
type='Folder',
id='patents',
id=patents_folder,
title='Patents',
container=api.content.get('/ca')
)

techoffer = patents.get("nova-oferta-tecnologica")
techoffer = patents.get(techoffer_folder)
logger.info("Getting technological offer folder")
if not techoffer:
logger.info("Technological offer folder not found, creating it at " +
" /ca/patents/nova-oferta-tecnologica")
f" /ca/{patents_folder}/{techoffer_folder}")
techoffer = api.content.create(
type='Folder',
id='nova-oferta-tecnologica',
id=techoffer_folder,
title='Oferta Tecnològica/Technological Offer (Nova versió)',
container=patents,
subject=tags
Expand Down
32 changes: 20 additions & 12 deletions src/genweb6/patents/browser/xml_form_config/FieldsModel.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<model xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="genweb6.patents" xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" xmlns:form="http://namespaces.plone.org/supermodel/form" xmlns:security="http://namespaces.plone.org/supermodel/security" xmlns:indexer="http://namespaces.plone.org/supermodel/indexer" xmlns:lingua="http://namespaces.plone.org/supermodel/lingua" xmlns:users="http://namespaces.plone.org/supermodel/users" xmlns:easyform="http://namespaces.plone.org/supermodel/easyform" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="title" type="zope.schema.TextLine" easyform:serverSide="False" easyform:THidden="False">
<description/>
<description>Màxim 150 caràcters./A maximum of 150 characters is allowed.</description>
<max_length>150</max_length>
<title i18n:translate="">Title</title>
<form:widget type="genweb6.patents.widgets.maxlengthtextfield.maxlengthtextfield.MaxLengthTextFieldWidget"/>
</field>
<field name="description" type="zope.schema.Text">
<description/>
<description>Màxim 500 caràcters./A maximum of 500 characters is allowed.</description>
<max_length>500</max_length>
<required>False</required>
<title i18n:translate="">Description</title>
<form:widget type="genweb6.patents.widgets.maxlengthtextareafield.maxlengthtextareafield.MaxLengthTextAreaFieldWidget"/>
</field>
<field name="ref_num" type="zope.schema.TextLine" easyform:serverSide="False" easyform:THidden="True">
<default>-</default>
Expand All @@ -20,24 +24,24 @@
<title>Categoria/Category</title>
<vocabulary>genweb6.patents.vocabularies.parent_categories</vocabulary>
</field>
<field name="challenge" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags1500" easyform:THidden="False">
<description i18n:translate="">challenge_description</description>
<field name="challenge" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags1100" easyform:THidden="False">
<description>Màxim 1100 caràcters. Pots veure el nombre de caràcters actuals clicant sobre el recompte de paraules que és a sota dreta d'aquesta caixa de text/A maximum of 1100 characters is allowed. You can see the current number of characters by clicking on the word count that is below on the right side of this text box.</description>
<title i18n:translate="">The Challenge</title>
</field>
<field name="technology" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags1500" easyform:THidden="False">
<description i18n:translate="">technology_description</description>
<field name="technology" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags1100" easyform:THidden="False">
<description>Màxim 1100 caràcters. Pots veure el nombre de caràcters actuals clicant sobre el recompte de paraules que és a sota dreta d'aquesta caixa de text/A maximum of 1100 characters is allowed. You can see the current number of characters by clicking on the word count that is below on the right side of this text box.</description>
<title i18n:translate="">Technology</title>
</field>
<field name="advantages" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags1500" easyform:THidden="False">
<description i18n:translate="">advantages_description</description>
<field name="advantages" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags1100" easyform:THidden="False">
<description>Màxim 1100 caràcters. Pots veure el nombre de caràcters actuals clicant sobre el recompte de paraules que és a sota dreta d'aquesta caixa de text/A maximum of 1100 characters is allowed. You can see the current number of characters by clicking on the word count that is below on the right side of this text box.</description>
<title i18n:translate="">Innovative advantages</title>
</field>
<field name="dev_stage" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags500" easyform:THidden="False">
<description i18n:translate="">dev_stage_description</description>
<description>Màxim 500 caràcters. Pots veure el nombre de caràcters actuals clicant sobre el recompte de paraules que és a sota dreta d'aquesta caixa de text/A maximum of 500 characters is allowed. You can see the current number of characters by clicking on the word count that is below on the right side of this text box.</description>
<title i18n:translate="">Current stage of development</title>
</field>
<field name="applications" type="plone.app.textfield.RichText" easyform:serverSide="False" easyform:validators="maxLengthNoTags500" easyform:THidden="False">
<description i18n:translate="">applications_description</description>
<description>Màxim 500 caràcters. Pots veure el nombre de caràcters actuals clicant sobre el recompte de paraules que és a sota dreta d'aquesta caixa de text/A maximum of 500 characters is allowed. You can see the current number of characters by clicking on the word count that is below on the right side of this text box.</description>
<title i18n:translate="">Applications and Target Market</title>
</field>
<field name="image1" type="plone.namedfile.field.NamedBlobImage">
Expand All @@ -46,19 +50,23 @@
<title i18n:translate="">First picture</title>
</field>
<field name="caption1" type="zope.schema.TextLine">
<description/>
<description>Màxim 200 caràcters./A maximum of 200 characters is allowed.</description>
<max_length>200</max_length>
<required>False</required>
<title>Comentari de la primera imatge/First picture caption</title>
<form:widget type="genweb6.patents.widgets.maxlengthtextfield.maxlengthtextfield.MaxLengthTextFieldWidget"/>
</field>
<field name="image2" type="plone.namedfile.field.NamedBlobImage" easyform:serverSide="False" easyform:THidden="False">
<description/>
<required>False</required>
<title i18n:translate="">Second picture</title>
</field>
<field name="caption2" type="zope.schema.TextLine">
<description/>
<description>Màxim 200 caràcters./A maximum of 200 characters is allowed.</description>
<max_length>200</max_length>
<required>False</required>
<title i18n:translate="">Second image caption</title>
<form:widget type="genweb6.patents.widgets.maxlengthtextfield.maxlengthtextfield.MaxLengthTextFieldWidget"/>
</field>
<field name="opportunity" type="zope.schema.Choice" easyform:serverSide="False" easyform:THidden="False">
<default>Technology available to be licensed</default>
Expand Down
1 change: 1 addition & 0 deletions src/genweb6/patents/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<include package="z3c.jbot" file="meta.zcml" />

<include package=".browser" />
<include package=".widgets" />

<include file="permissions.zcml" />
<include file="upgrades.zcml" />
Expand Down
24 changes: 18 additions & 6 deletions src/genweb6/patents/content/techoffer/techoffer.pt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<metal:content-core fill-slot="main">
<header>
<img tal:attributes="src string:${context/absolute_url}/@@gw-logo"
class="print-only" id='head-upc-logo' />
class="print-only mb-0" id='head-upc-logo' width="200"
style="margin-bottom: 0.5rem !important;"/>
<div id="social_tags">
<a target="_blank" tal:attributes="href python: f'https://twitter.com/intent/tweet?url={context.absolute_url()}&amp;text=Equip humà'" title="Twitter">
<i class="bi bi-twitter"></i>
Expand All @@ -31,13 +32,13 @@
<i class="bi bi-printer"></i>
</a>
</div>
<h1 tal:content="context/title"></h1>
<h1 class="no-print" tal:content="context/title"></h1>
</header>
<metal:block define-macro="content-core">
<div id="content-core">
<p>
<p class="no-print">
<strong>
<span tal:content='context/description'></span> Ref. <span
<span class="content-description" tal:content='context/description'></span> Ref. <span
tal:content="context/ref_num"></span>
</strong>
</p>
Expand All @@ -52,6 +53,13 @@
<div id="parent-fieldname-text">
<div class="row-fluid">
<div class="span9">
<header class="print-only">
<h1 tal:content="context/title"></h1>
<p>
<strong tal:content="context/description"></strong>
Ref: <span tal:content="context/ref_num"></span>
</p>
</header>
<div class="box">
<div class="print-no-break">
<h3 i18n:translate="">The Challenge</h3>
Expand Down Expand Up @@ -85,14 +93,18 @@
class="span3">

<tal:img1block tal:condition="python: bool(image1_large)">
<img tal:replace="structure python: image1_large.tag()" />
<div class="to-image">
<img tal:replace="structure python: image1_large.tag()" />
</div>
<p tal:define="caption context/caption1 | nothing"
tal:condition="python: bool(caption)"
class="card p-3 text-bg-light mb-4" tal:content="caption"></p>
</tal:img1block>

<tal:img2block tal:condition="python: bool(image2_large)">
<img tal:replace="structure python: image2_large.tag()" />
<div class="to-image">
<img tal:replace="structure python: image2_large.tag()" />
</div>
<p tal:define="caption context/caption2 | nothing"
tal:condition="python: bool(caption)"
class="card p-3 text-bg-light mb-4" tal:content="caption"></p>
Expand Down
49 changes: 34 additions & 15 deletions src/genweb6/patents/content/techoffer/techoffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from zope import schema
from zope.interface import implementer, invariant, Invalid # noqa F401
from genweb6.patents.validators import maxLengthValidatorNoTags
from plone.autoform import directives
from genweb6.patents.widgets.maxlengthtextfield.maxlengthtextfield import MaxLengthTextFieldWidget
from genweb6.patents.widgets.maxlengthtextareafield.maxlengthtextareafield import (
MaxLengthTextAreaFieldWidget
)


def max_length_validator(max_length):
Expand All @@ -32,17 +37,21 @@ def validator(value):

class ITechOffer(model.Schema, IDexteritySchema):
textindexer.searchable('title')
directives.widget('title', MaxLengthTextFieldWidget)
title = schema.TextLine(
title=_(u"Title"),
description=u"",
required=True
description=_(u"max_length_textfield_info", mapping={'max': 150}),
required=True,
max_length=150
)

textindexer.searchable('description')
directives.widget('description', MaxLengthTextAreaFieldWidget)
description = schema.Text(
title=_(u"Description"),
description=u"",
required=False
description=_(u"max_length_textfield_info", mapping={'max': 500}),
required=False,
max_length=500
)

textindexer.searchable('ref_num')
Expand All @@ -55,35 +64,35 @@ class ITechOffer(model.Schema, IDexteritySchema):
textindexer.searchable('challenge')
challenge = RichText(
title=_(u"The Challenge"),
description=_(u"challenge_description"),
constraint=max_length_validator(1500)
description=_(u"max_length_info", mapping={'max': 1100}),
constraint=max_length_validator(1100)
)

textindexer.searchable('technology')
technology = RichText(
title=_(u"Technology"),
description=_(u"technology_description"),
constraint=max_length_validator(1500)
description=_(u"max_length_info", mapping={"max": 1100}),
constraint=max_length_validator(1100)
)

textindexer.searchable('advantages')
advantages = RichText(
title=_(u"Innovative advantages"),
description=_(u"advantages_description"),
constraint=max_length_validator(1500)
description=_(u"max_length_info", mapping={"max": 1100}),
constraint=max_length_validator(1100)
)

textindexer.searchable('dev_stage')
dev_stage = RichText(
title=_(u"Current stage of development"),
description=_(u"dev_stage_description"),
description=_(u"max_length_info", mapping={"max": 500}),
constraint=max_length_validator(500)
)

textindexer.searchable('applications')
applications = RichText(
title=_(u"Applications and Target Market"),
description=_(u"applications_description"),
description=_(u"max_length_info", mapping={"max": 500}),
constraint=max_length_validator(500)
)

Expand All @@ -97,17 +106,26 @@ class ITechOffer(model.Schema, IDexteritySchema):
title=_(u"First picture"),
required=False
)

directives.widget('caption1', MaxLengthTextFieldWidget)
caption1 = schema.TextLine(
title=_(u"First picture caption"),
required=False
required=False,
description=_(u"max_length_textfield_info", mapping={'max': 200}),
max_length=200

)
image2 = namedfile.NamedBlobImage(
title=_(u"Second picture"),
required=False
)

directives.widget('caption2', MaxLengthTextFieldWidget)
caption2 = schema.TextLine(
title=_(u"Second image caption"),
required=False
required=False,
description=_(u"max_length_textfield_info", mapping={'max': 200}),
max_length=200
)

opportunity = schema.Choice(
Expand All @@ -116,7 +134,8 @@ class ITechOffer(model.Schema, IDexteritySchema):
)
other_opportunity = schema.TextLine(
title=_(u"Specify Business Opportunity"),
description=_(u"Fill this field if you selected 'Others' for 'Business Opportunity'"),
description=_(
u"Fill this field if you selected 'Others' for 'Business Opportunity'"),
required=False
)

Expand Down
Loading

0 comments on commit 86afd3b

Please sign in to comment.