Coverage for portality/forms/application_forms.py: 78%

758 statements  

« prev     ^ index     » next       coverage.py v7.17.3, created at 2026-11-20 13:43 +0000

1""" 

2~~ApplicationForm:Feature~~ 

3""" 

4from copy import deepcopy 

5 

6from wtforms import StringField, TextAreaField, IntegerField, BooleanField, SelectMultipleField, \ 

7 SelectField, \ 

8 FormField, FieldList, HiddenField, DateField 

9from wtforms import widgets, validators 

10from wtforms.widgets.core import html_params, HTMLString 

11 

12from flask_babel import lazy_gettext 

13 

14from portality import constants 

15from portality import regex 

16from portality.core import app 

17from portality.crosswalks.application_form import ApplicationFormXWalk 

18from portality.crosswalks.journal_form import JournalFormXWalk 

19from portality.datasets import language_options, country_options, currency_options 

20from portality.forms import application_processors 

21from portality.forms.fields import TagListField, NestedFormField, UnconstrainedRadioField 

22from portality.forms.validate import ( 

23 HTTPURL, 

24 OptionalIf, 

25 MaxLen, 

26 RegexpOnTagList, 

27 StopWords, 

28 ISSNInPublicDOAJ, 

29 JournalURLInPublicDOAJ, 

30 DifferentTo, 

31 RequiredIfOtherValue, 

32 RequiredIfActive, 

33 OnlyIf, 

34 OnlyIfExists, 

35 NotIf, 

36 GroupMember, 

37 RequiredValue, 

38 BigEndDate, 

39 ReservedUsernames, 

40 CustomRequired, 

41 OwnerExists, 

42 NoScriptTag, 

43 Year, 

44 CurrentISOCurrency, 

45 CurrentISOLanguage, 

46 DateInThePast, 

47 NotValue, 

48 ForbiddenWord, 

49 StopValidationOnOtherValue 

50) 

51from portality.lib import dates 

52from portality.lib.formulaic import Formulaic, WTFormsBuilder, FormulaicContext, FormulaicField 

53from portality.models import EditorGroup 

54from portality.regex import ISSN, ISSN_COMPILED 

55from portality.ui.messages import Messages 

56from portality.ui import templates 

57 

58# Stop words used in the keywords field 

59STOP_WORDS = [ 

60 "open access", 

61 "high quality", 

62 "peer-reviewed", 

63 "peer-review", 

64 "peer review", 

65 "peer reviewed", 

66 "quality", 

67 "medical journal", 

68 "multidisciplinary", 

69 "multi-disciplinary", 

70 "multi-disciplinary journal", 

71 "interdisciplinary", 

72 "inter disciplinary", 

73 "inter disciplinary research", 

74 "international journal", 

75 "journal", 

76 "scholarly journal", 

77 "open science", 

78 "impact factor", 

79 "scholarly", 

80 "research", 

81 "research journal" 

82] 

83 

84 

85######################################################## 

86# Define all our individual fields 

87######################################################## 

88 

89class FieldDefinitions: 

90 # ~~->$ BOAI:FormField~~ 

91 BOAI = { 

92 "name": "boai", 

93 "label": lazy_gettext("Does the journal adhere to DOAJ’s definition of open access?"), 

94 "input": "radio", 

95 "options": [ 

96 {"display": lazy_gettext("Yes"), "value": "y"}, 

97 {"display": lazy_gettext("No"), "value": "n"} 

98 ], 

99 "help": { 

100 "long_help": [lazy_gettext("See <a href='https://blog.doaj.org/2020/11/17/" 

101 "what-does-doaj-define-as-open-access/' " 

102 "target='_blank' rel='noopener'>" 

103 "DOAJ’s definition of open access explained " 

104 "in full</a>.")], 

105 "doaj_criteria": lazy_gettext("You must answer 'Yes'") 

106 }, 

107 "validate": [ 

108 {"required": {"message": lazy_gettext("You must answer <strong>Yes</strong> to continue")}}, 

109 {"required_value": {"value": "y"}} 

110 ], 

111 "contexts": { 

112 "admin": { 

113 "validate": [] 

114 }, 

115 "editor": { 

116 "validate": [], 

117 "disabled": True 

118 }, 

119 "associate_editor": { 

120 "validate": [], 

121 "disabled": True 

122 } 

123 } 

124 } 

125 

126 # ~~->$ OAStatementURL:FormField~~ 

127 OA_STATEMENT_URL = { 

128 "name": "oa_statement_url", 

129 "label": lazy_gettext("The journal website must display its open access statement. Where can we find this information?"), 

130 "input": "text", 

131 "help": { 

132 "long_help": [lazy_gettext("Here is an example of a suitable Open Access " 

133 "statement that meets our criteria: <blockquote>This" 

134 " is an open access journal, which means that all " 

135 "content is freely available without charge to the " 

136 "user or his/her institution. Users are allowed to " 

137 "read, download, copy, distribute, print, search, or" 

138 " link to the full texts of the articles, or use " 

139 "them for any other lawful purpose, without asking " 

140 "prior permission from the publisher or the author. " 

141 "This is in accordance with the BOAI definition of " 

142 "open access.</blockquote>")], 

143 "short_help": lazy_gettext("Link to the journal’s open access statement"), 

144 "placeholder": "https://www.my-journal.com/open-access" 

145 }, 

146 "validate": [ 

147 {"required": {"message": lazy_gettext("Enter the URL for the journal’s Open Access statement page")}}, 

148 "is_url" # ~~^->IsURL:FormValidator~~ 

149 ], 

150 "widgets": [ 

151 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

152 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

153 ], 

154 "attr": { 

155 "type": "url" 

156 } 

157 } 

158 

159 # ~~->$ Title:FormField~~ 

160 TITLE = { 

161 "name": "title", 

162 "label": lazy_gettext("Journal title"), 

163 "input": "text", 

164 "help": { 

165 "long_help": [lazy_gettext("The journal title must match what is displayed on the website and what is registered at the " 

166 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

167 lazy_gettext("For translated titles, you may add the " 

168 "translation as an alternative title.")], 

169 "placeholder": lazy_gettext("Journal title"), 

170 "doaj_criteria": lazy_gettext("Title in application form, title at ISSN and website must all match") 

171 }, 

172 "validate": [ 

173 {"required": {"message": lazy_gettext("Enter the journal’s name")}}, 

174 "no_script_tag" # ~~^-> NoScriptTag:FormValidator 

175 ], 

176 "widgets": [ 

177 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

178 "full_contents" # ~~^->FullContents:FormWidget~~ 

179 ], 

180 "contexts": { 

181 "admin": { 

182 "widgets": [ 

183 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

184 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

185 ] 

186 }, 

187 "editor": { 

188 "disabled": True, 

189 "widgets": [ 

190 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

191 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

192 ] 

193 }, 

194 "associate_editor": { 

195 "disabled": True, 

196 "widgets": [ 

197 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

198 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

199 ] 

200 }, 

201 "update_request": { 

202 "disabled": True 

203 } 

204 } 

205 } 

206 

207 # ~~->$ AlternativeTitle:FormField~~ 

208 ALTERNATIVE_TITLE = { 

209 "name": "alternative_title", 

210 "label": lazy_gettext("Alternative title (including translation of the title)"), 

211 "input": "text", 

212 "optional": True, 

213 "help": { 

214 "placeholder": "Mi revista" 

215 }, 

216 "validate": [ 

217 "no_script_tag" # ~~^-> NoScriptTag:FormValidator 

218 ], 

219 "widgets": [ 

220 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

221 {"full_contents": {"empty_disabled": "[The journal has no alternative title]"}} 

222 # ~~^->FullContents:FormWidget~~ 

223 ], 

224 "contexts": { 

225 "update_request": { 

226 "disabled": True 

227 }, 

228 "admin": { 

229 "widgets": [ 

230 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

231 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

232 ] 

233 }, 

234 "associate_editor": { 

235 "widgets": [ 

236 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

237 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

238 ] 

239 }, 

240 "editor": { 

241 "widgets": [ 

242 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

243 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

244 ] 

245 } 

246 } 

247 } 

248 

249 # ~~->$ JournalURL:FormField~~ 

250 JOURNAL_URL = { 

251 "name": "journal_url", 

252 "label": lazy_gettext("Link to the journal’s homepage"), 

253 "input": "text", 

254 "validate": [ 

255 "required", 

256 "is_url" # ~~^->IsURL:FormValidator~~ 

257 ], 

258 "widgets": [ 

259 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

260 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

261 ], 

262 "help": { 

263 "placeholder": "https://www.my-journal.com" 

264 }, 

265 "contexts": { 

266 "public": { 

267 "validate": [ 

268 {"required": {"message": lazy_gettext("Enter the URL for the journal’s <strong>homepage</strong>")}}, 

269 "is_url", # ~~^->IsURL:FormValidator~~ 

270 "journal_url_in_public_doaj" # ~~^-> JournalURLInPublicDOAJ:FormValidator~~ 

271 ], 

272 } 

273 } 

274 } 

275 

276 # ~~->$ PISSN:FormField~~ 

277 PISSN = { 

278 "name": "pissn", 

279 "label": lazy_gettext("ISSN (print)"), 

280 "input": "text", 

281 "help": { 

282 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

283 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

284 lazy_gettext("Use the link under the ISSN you provided to check it."), 

285 lazy_gettext("The ISSN must match what is given on the journal website.")], 

286 "short_help": lazy_gettext("For example, 2049-3630"), 

287 "doaj_criteria": lazy_gettext("ISSN must be provided") 

288 }, 

289 "validate": [ 

290 {"optional_if": {"field": "eissn", # ~~^-> OptionalIf:FormValidator~~ 

291 "message": lazy_gettext("You must provide <strong>one or both</strong> an online ISSN or a print ISSN")}}, 

292 {"is_issn": {"message": lazy_gettext("This is not a valid ISSN")}}, # ~~^-> IsISSN:FormValidator~~ 

293 {"different_to": {"field": "eissn", "message": lazy_gettext("This field must contain a different value to 'ISSN (" 

294 "online)'")}} # ~~^-> DifferetTo:FormValidator~~ 

295 ], 

296 "widgets": [ 

297 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

298 "full_contents", # ~~^->FullContents:FormWidget~~ 

299 "issn_link" # ~~^->IssnLink:FormWidget~~ 

300 ], 

301 "contexts": { 

302 "public": { 

303 "validate": [ 

304 {"optional_if": {"field": "eissn", # ~~^-> OptionalIf:FormValidator~~ 

305 "message": lazy_gettext("You must provide <strong>one or both</strong> an online ISSN or a print ISSN")}}, 

306 {"is_issn": {"message": lazy_gettext("This is not a valid ISSN")}}, # ~~^-> IsISSN:FormValidator~~ 

307 {"different_to": {"field": "eissn", 

308 "message": lazy_gettext("This field must contain a different value to 'ISSN (" 

309 "online)'")}}, # ~~^-> DifferetTo:FormValidator~~ 

310 "issn_in_public_doaj" 

311 ], 

312 }, 

313 "admin": { 

314 "help": { 

315 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

316 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

317 lazy_gettext("The ISSN must match what is given on the journal website.")], 

318 "placeholder": "", 

319 "doaj_criteria": lazy_gettext("ISSN must be provided") 

320 }, 

321 "widgets": [ 

322 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

323 "autocheck", # ~~^-> Autocheck:FormWidget~~ 

324 "issn_link" # ~~^->IssnLink:FormWidget~~ 

325 ] 

326 }, 

327 "editor": { 

328 "disabled": True, 

329 "help": { 

330 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

331 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

332 lazy_gettext("The ISSN must match what is given on the journal website.")], 

333 "placeholder": "", 

334 "doaj_criteria": lazy_gettext("ISSN must be provided") 

335 }, 

336 }, 

337 "associate_editor": { 

338 "disabled": True, 

339 "help": { 

340 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

341 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

342 lazy_gettext("The ISSN must match what is given on the journal website.")], 

343 "placeholder": "", 

344 "doaj_criteria": lazy_gettext("ISSN must be provided") 

345 } 

346 }, 

347 "update_request": { 

348 "disabled": True 

349 } 

350 } 

351 } 

352 

353 # ~~->$ EISSN:FormField~~ 

354 EISSN = { 

355 "name": "eissn", 

356 "label": lazy_gettext("ISSN (online)"), 

357 "input": "text", 

358 "help": { 

359 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

360 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

361 lazy_gettext("Use the link under the ISSN you provided to check it."), 

362 lazy_gettext("The ISSN must match what is given on the journal website.")], 

363 "short_help": lazy_gettext("For example, 0378-5955"), 

364 "doaj_criteria": lazy_gettext("ISSN must be provided") 

365 }, 

366 "validate": [ 

367 {"optional_if": {"field": "pissn", # ~~^-> OptionalIf:FormValidator~~ 

368 "message": lazy_gettext("You must provide <strong>one or both</strong> an online ISSN or a print ISSN")}}, 

369 {"is_issn": {"message": lazy_gettext("This is not a valid ISSN")}}, # ~~^-> IsISSN:FormValidator~~ 

370 {"different_to": {"field": "pissn", 

371 "message": lazy_gettext("This field must contain a different value to 'ISSN (print)'")}} 

372 # ~~^-> DifferetTo:FormValidator~~ 

373 ], 

374 "widgets": [ 

375 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

376 "full_contents", # ~~^->FullContents:FormWidget~~ 

377 "issn_link" # ~~^->IssnLink:FormWidget~~ 

378 ], 

379 "contexts": { 

380 "public": { 

381 "validate": [ 

382 {"optional_if": {"field": "pissn", # ~~^-> OptionalIf:FormValidator~~ 

383 "message": lazy_gettext("You must provide <strong>one or both</strong> an online ISSN or a print ISSN")}}, 

384 {"is_issn": {"message": lazy_gettext("This is not a valid ISSN")}}, # ~~^-> IsISSN:FormValidator~~ 

385 {"different_to": {"field": "pissn", 

386 "message": lazy_gettext("This field must contain a different value to 'ISSN (print)'")}}, 

387 # ~~^-> DifferetTo:FormValidator~~ 

388 "issn_in_public_doaj" 

389 ] 

390 }, 

391 "admin": { 

392 "help": { 

393 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

394 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

395 lazy_gettext("The ISSN must match what is given on the journal website.")], 

396 "placeholder": "", 

397 "doaj_criteria": lazy_gettext("ISSN must be provided") 

398 }, 

399 "widgets": [ 

400 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

401 "autocheck", # ~~^-> Autocheck:FormWidget~~ 

402 "issn_link" # ~~^->IssnLink:FormWidget~~ 

403 ] 

404 }, 

405 "editor": { 

406 "disabled": True, 

407 "help": { 

408 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

409 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

410 lazy_gettext("The ISSN must match what is given on the journal website.")], 

411 "placeholder": "", 

412 "doaj_criteria": lazy_gettext("ISSN must be provided") 

413 }, 

414 }, 

415 "associate_editor": { 

416 "disabled": True, 

417 "help": { 

418 "long_help": [lazy_gettext("Must be a valid ISSN, fully registered and confirmed at the " 

419 "<a href='https://portal.issn.org/' target='_blank' rel='noopener'> ISSN Portal</a>."), 

420 lazy_gettext("The ISSN must match what is given on the journal website.")], 

421 "placeholder": "", 

422 "doaj_criteria": lazy_gettext("ISSN must be provided") 

423 } 

424 }, 

425 "update_request": { 

426 "disabled": True, 

427 "validate": [ 

428 {"optional_if": {"field": "pissn", # ~~^-> OptionalIf:FormValidator~~ 

429 "message": lazy_gettext("You must provide <strong>one or both</strong> an online ISSN or a print ISSN")}}, 

430 {"is_issn": {"message": lazy_gettext("This is not a valid ISSN")}}, # ~~^-> IsISSN:FormValidator~~ 

431 {"different_to": {"field": "pissn", # ~~^-> DifferetTo:FormValidator~~ 

432 "message": lazy_gettext("This field must contain a different value to 'ISSN (print)'")}} 

433 ] 

434 } 

435 } 

436 } 

437 

438 # ~~->$ Keywords:FormField~~ 

439 KEYWORDS = { 

440 "name": "keywords", 

441 "label": lazy_gettext("Up to 6 subject keywords in English"), 

442 "input": "taglist", 

443 "help": { 

444 "long_help": [lazy_gettext("Choose up to 6 keywords that describe the journal's subject matter. " 

445 "Keywords must be in English."), lazy_gettext("Use single words or short phrases (2 to 3 words) " 

446 "that describe the journal's main topic."), 

447 lazy_gettext("Do not add acronyms, abbreviations or descriptive sentences."), 

448 lazy_gettext("Note that the keywords may be edited by DOAJ editorial staff.")], 

449 }, 

450 "validate": [ 

451 {"required": {"message": lazy_gettext("Enter at least <strong>one subject keyword</strong> in English")}}, 

452 {"stop_words": {"disallowed": STOP_WORDS}}, # ~~^->StopWords:FormValidator~~ 

453 {"max_tags": {"max": 6}} 

454 ], 

455 "widgets": [ 

456 { 

457 "taglist": { 

458 "maximumSelectionSize": 6, 

459 "stopWords": STOP_WORDS, 

460 "field": "bibjson.keywords" 

461 } 

462 } 

463 ], 

464 "attr": { 

465 "class": "input-xlarge" 

466 } 

467 } 

468 

469 # ~~->$ Language:FormField~~ 

470 LANGUAGE = { 

471 "name": "language", 

472 "label": lazy_gettext("Languages in which the journal accepts manuscripts"), 

473 "input": "select", 

474 "default": "", 

475 "options_fn": "iso_language_list", 

476 "repeatable": { 

477 "label": lazy_gettext("Language"), 

478 "minimum": 1, 

479 "initial": 5 

480 }, 

481 "validate": [ 

482 {"required": {"message": lazy_gettext("Enter <strong>at least one</strong> language")}}, 

483 "current_iso_language" 

484 ], 

485 "widgets": [ 

486 {"select": {}}, 

487 "multiple_field" 

488 ], 

489 "help": { 

490 "placeholder": lazy_gettext("Type or select the language") 

491 }, 

492 "attr": { 

493 "class": "input-xlarge unstyled-list" 

494 } 

495 } 

496 

497 # ~~->$ PublisherName:FormField~~ 

498 PUBLISHER_NAME = { 

499 "name": "publisher_name", 

500 "label": lazy_gettext("Publisher's name"), 

501 "input": "text", 

502 "validate": [ 

503 {"required": {"message": lazy_gettext("Enter the name of the journal's publisher")}}, 

504 ], 

505 "widgets": [ 

506 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

507 {"autocomplete": {"type": "journal", "field": "bibjson.publisher.name.exact"}}, 

508 # ~~^-> Autocomplete:FormWidget~~ 

509 "full_contents" # ~~^->FullContents:FormWidget~~ 

510 ], 

511 "help": { 

512 "placeholder": lazy_gettext("Type or select the publisher's name") 

513 }, 

514 "contexts": { 

515 "bulk_edit": { 

516 "validate": [] 

517 }, 

518 "admin": { 

519 "widgets": [ 

520 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

521 {"autocomplete": {"type": "journal", "field": "bibjson.publisher.name.exact"}}, 

522 # ~~^-> Autocomplete:FormWidget~~ 

523 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

524 ] 

525 }, 

526 "public": { 

527 "validate": [ 

528 {"required": {"message": lazy_gettext("Enter the name of the journal's publisher")}}, 

529 {"different_to": {"field": "institution_name", 

530 "message": lazy_gettext("The Publisher's name and Other organisation's name cannot be the same.")}} 

531 ] 

532 # ~~^-> DifferetTo:FormValidator~~ 

533 

534 }, 

535 "update_request": { 

536 "validate": [ 

537 {"required": {"message": lazy_gettext("Enter the name of the journal's publisher")}}, 

538 {"different_to": {"field": "institution_name", 

539 "message": lazy_gettext("The Publisher's name and Other organisation's name cannot be the same.")}} 

540 ] 

541 # ~~^-> DifferetTo:FormValidator~~ 

542 

543 }, 

544 "associate_editor": { 

545 "widgets": [ 

546 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

547 {"autocomplete": {"type": "journal", "field": "bibjson.publisher.name.exact"}}, 

548 # ~~^-> Autocomplete:FormWidget~~ 

549 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

550 ] 

551 }, 

552 "editor": { 

553 "widgets": [ 

554 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

555 {"autocomplete": {"type": "journal", "field": "bibjson.publisher.name.exact"}}, 

556 # ~~^-> Autocomplete:FormWidget~~ 

557 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

558 ] 

559 } 

560 } 

561 } 

562 

563 # ~~->$ PublisherCountry:FormField~~ 

564 PUBLISHER_COUNTRY = { 

565 "name": "publisher_country", 

566 "label": lazy_gettext("Publisher's country"), 

567 "input": "select", 

568 "default": "", 

569 "options_fn": "iso_country_list", 

570 "help": { 

571 "long_help": [lazy_gettext("The country where the publisher carries out its business operations and is registered.")], 

572 "doaj_criteria": lazy_gettext("You must provide a publisher country"), 

573 "placeholder": lazy_gettext("Type or select the country") 

574 }, 

575 "validate": [ 

576 {"required": { 

577 "message": lazy_gettext("Enter the <strong>country</strong> where the publisher carries out its business operations and is registered")}} 

578 ], 

579 "widgets": [ 

580 {"select": {}} 

581 ], 

582 "attr": { 

583 "class": "input-xlarge" 

584 }, 

585 "contexts": { 

586 "associate_editor": { 

587 "disabled": True 

588 }, 

589 "bulk_edit": { 

590 "validate": [] 

591 }, 

592 # ~~^-> PreassessmentChecklist:FormWidget~~ 

593 # Issue #4421: on the public new-application form only, when the 

594 # publisher's country is Mexico or Indonesia, show a required 

595 # "I confirm..." checkbox below the country field (UI-only - its state 

596 # is never saved as part of the Application, so there's no 

597 # corresponding real form field/data model change). Deliberately 

598 # scoped to "public" only (not update_request/editor/admin/etc, which 

599 # share this same field definition) - the checklist is about 

600 # readiness to *submit* a new application, not for staff reviewing one 

601 # or a publisher updating an existing DOAJ-listed journal. 

602 # Country values below are ISO 3166 alpha-2 codes (see iso_country_list 

603 # / portality.datasets.country_options), NOT the country names. 

604 "public": { 

605 "widgets": [ 

606 {"select": {}}, 

607 {"preassessment_checklist": { 

608 "countries": { 

609 # Spanish-language pre-assessment checklist (Google Form) 

610 "MX": {"checklist_url": "https://docs.google.com/forms/d/e/1FAIpQLSceng2wJmSC5NElurptCh2bweAVcwgRzaf5QK0TgPXnDS2Acg/viewform"}, 

611 # English-language pre-assessment checklist (Google Form) 

612 "ID": {"checklist_url": "https://docs.google.com/forms/d/e/1FAIpQLSeIjmsXhlUL1GCsKHC5LZ_wc0LsDzlONzOQKpRrSSw5F4ZfBQ/viewform?usp=header"}, 

613 }, 

614 "blog_url": "https://blog.doaj.org/2026/09/28/using-our-new-pre-assessment-checklist-an-invitation-to-mexican-and-indonesian-journals/" 

615 }} 

616 ] 

617 } 

618 } 

619 } 

620 

621 # ~~->$ InstitutionName:FormField~~ 

622 INSTITUTION_NAME = { 

623 "name": "institution_name", 

624 "label": lazy_gettext("Other organisation's name"), 

625 "input": "text", 

626 "optional": True, 

627 "help": { 

628 "short_help": lazy_gettext("Any other organisation associated with the journal"), 

629 "long_help": [ 

630 lazy_gettext("The journal may be owned, funded, sponsored, or supported by another organisation that is not " 

631 "the publisher. If your journal is linked to " 

632 "a second organisation, enter its name here.")], 

633 "placeholder": lazy_gettext("Type or select the other organisation's name") 

634 }, 

635 "widgets": [ 

636 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

637 {"autocomplete": {"type": "journal", "field": "bibjson.institution.name.exact"}}, 

638 # ~~^-> Autocomplete:FormWidget~~ 

639 "full_contents" # ~~^->FullContents:FormWidget~~ 

640 ], 

641 "validate": [ 

642 {"not_value": { 

643 "value": "None", 

644 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

645 }} # ~~^-> NotValue:FormValidator~~ 

646 ], 

647 "contexts": { 

648 "public": { 

649 "validate": [ 

650 {"different_to": {"field": "publisher_name", 

651 "message": lazy_gettext("The Publisher's name and Other organisation's name cannot be the same.")}}, 

652 # ~~^-> DifferetTo:FormValidator~~ 

653 {"not_value": { 

654 "value": "None", 

655 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

656 }} # ~~^-> NotValue:FormValidator~~ 

657 ] 

658 }, 

659 "update_request": { 

660 "validate": [ 

661 {"different_to": {"field": "publisher_name", 

662 "message": lazy_gettext("The Publisher's name and Other organisation's name cannot be the same.")}}, 

663 # ~~^-> DifferetTo:FormValidator~~ 

664 {"not_value": { 

665 "value": "None", 

666 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

667 }} # ~~^-> NotValue:FormValidator~~ 

668 ] 

669 }, 

670 "admin": { 

671 "widgets": [ 

672 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

673 {"autocomplete": {"type": "journal", "field": "bibjson.institution.name.exact"}}, 

674 # ~~^-> Autocomplete:FormWidget~~ 

675 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

676 ] 

677 }, 

678 "associate_editor": { 

679 "widgets": [ 

680 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

681 {"autocomplete": {"type": "journal", "field": "bibjson.institution.name.exact"}}, 

682 # ~~^-> Autocomplete:FormWidget~~ 

683 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

684 ] 

685 }, 

686 "editor": { 

687 "widgets": [ 

688 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

689 {"autocomplete": {"type": "journal", "field": "bibjson.institution.name.exact"}}, 

690 # ~~^-> Autocomplete:FormWidget~~ 

691 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

692 ] 

693 } 

694 } 

695 } 

696 

697 # ~~->$ InstitutionCountry:FormField~~ 

698 INSTITUTION_COUNTRY = { 

699 "name": "institution_country", 

700 "label": lazy_gettext("Other organisation's country"), 

701 "input": "select", 

702 "default": "", 

703 "options_fn": "iso_country_list", 

704 "optional": True, 

705 "help": { 

706 "short_help": lazy_gettext("The country in which the other organisation is based"), 

707 "placeholder": lazy_gettext("Type or select the country") 

708 }, 

709 "widgets": [ 

710 {"select": {"allow_clear": True}} 

711 ], 

712 "contexts": { 

713 "public": { 

714 "validate": [ 

715 { 

716 "only_if_exists": { 

717 "fields": 

718 [{"field": "institution_name"}], 

719 "message": lazy_gettext("'You must provide the other organization's name. You cannot provide just the country."), 

720 } 

721 } 

722 ] 

723 }, 

724 "update_request": { 

725 "validate": [ 

726 { 

727 "only_if_exists": { 

728 "fields": 

729 [{"field": "institution_name"}], 

730 "message": lazy_gettext("'You must provide the other organization's name. You cannot provide just the country."), 

731 } 

732 } 

733 ] 

734 }, 

735 }, 

736 "attr": { 

737 "class": "input-xlarge" 

738 } 

739 } 

740 

741 # ~~->$ License:FormField~~ 

742 LICENSE = { 

743 "name": "license", 

744 "label": lazy_gettext("License(s) permitted by the journal"), 

745 "input": "checkbox", 

746 "multiple": True, 

747 "options": [ 

748 {"display": lazy_gettext("CC BY"), "value": "CC BY"}, 

749 {"display": lazy_gettext("CC BY-SA"), "value": "CC BY-SA"}, 

750 {"display": lazy_gettext("CC BY-ND"), "value": "CC BY-ND"}, 

751 {"display": lazy_gettext("CC BY-NC"), "value": "CC BY-NC"}, 

752 {"display": lazy_gettext("CC BY-NC-SA"), "value": "CC BY-NC-SA"}, 

753 {"display": lazy_gettext("CC BY-NC-ND"), "value": "CC BY-NC-ND"}, 

754 {"display": lazy_gettext("CC0"), "value": "CC0"}, 

755 {"display": lazy_gettext("Public domain"), "value": "Public domain"}, 

756 {"display": lazy_gettext("Publisher's own license"), "value": "Publisher's own license", 

757 "subfields": ["license_attributes"]}, 

758 ], 

759 "help": { 

760 "long_help": [lazy_gettext("The journal must use some form of licensing to be considered for indexing in DOAJ. "), 

761 lazy_gettext("If Creative Commons licensing is not used, then select <em>Publisher's own license</em> and enter " 

762 "more details below."), 

763 lazy_gettext("More information on CC licenses: <br/>" 

764 "<a href='https://creativecommons.org/licenses/by/4.0/" 

765 "' target='_blank' 'rel='noopener'>CC BY</a> <br/>" 

766 "<a href='https://creativecommons.org/licenses/by-sa/4.0/" 

767 "' target='_blank' 'rel='noopener'>CC BY-SA</a> <br/>" 

768 "<a href='https://creativecommons.org/licenses/by-nd/4.0/" 

769 "' target='_blank' 'rel='noopener'>CC BY-ND</a> <br/>" 

770 "<a href='https://creativecommons.org/licenses/by-nc/4.0/" 

771 "' target='_blank' 'rel='noopener'>CC BY-NC</a> <br/>" 

772 "<a href='https://creativecommons.org/licenses/by-nc-sa/4.0/" 

773 "' target='_blank' 'rel='noopener'>CC BY-NC-SA</a> <br/>" 

774 "<a href='https://creativecommons.org/licenses/by-nc-nd/4.0/" 

775 "' target='_blank' 'rel='noopener'>CC BY-NC-ND</a>"), 

776 lazy_gettext("<a href='https://wiki.creativecommons.org/wiki/CC0_" 

777 "FAQ#What_is_the_difference_between_CC0_and_the_Publ" 

778 "ic_Domain_Mark_.28.22PDM.22.29.3F' target='_blank' " 

779 "rel='noopener'>What is the difference between CC0 " 

780 "and the Public Domain Mark (\"PDM\")?</a>")], 

781 "doaj_criteria": lazy_gettext("Content must be licensed") 

782 }, 

783 "validate": [ 

784 {"required": {"message": lazy_gettext("Select <strong>at least one</strong> type of license")}} 

785 ] 

786 } 

787 

788 # ~~->$ LicenseAttributes:FormField~~ 

789 LICENSE_ATTRIBUTES = { 

790 "name": "license_attributes", 

791 "label": lazy_gettext("Select all the attributes that your license has"), 

792 "input": "checkbox", 

793 "multiple": True, 

794 "conditional": [ 

795 {"field": "license", "value": "Publisher's own license"} 

796 ], 

797 "options": [ 

798 {"display": lazy_gettext("Attribution"), "value": "BY"}, 

799 {"display": lazy_gettext("Share Alike"), "value": "SA"}, 

800 {"display": lazy_gettext("No Derivatives"), "value": "ND"}, 

801 {"display": lazy_gettext("No Commercial Usage"), "value": "NC"} 

802 ], 

803 "help": { 

804 "doaj_criteria": lazy_gettext("Content must be licensed") 

805 } 

806 } 

807 

808 # ~~->$ LicenseTermsURL:FormField~~ 

809 LICENSE_TERMS_URL = { 

810 "name": "license_terms_url", 

811 "label": lazy_gettext("Where can we find this information?"), 

812 "input": "text", 

813 "diff_table_context": "License terms", 

814 "validate": [ 

815 {"required": {"message": lazy_gettext("Enter the URL for the journal’s <strong>license terms</strong> page")}}, 

816 "is_url" # ~~^->IsURL:FormValidator~~ 

817 ], 

818 "help": { 

819 "short_help": lazy_gettext("Link to the page where the license terms are stated on your site."), 

820 "doaj_criteria": lazy_gettext("You must provide a link to your license terms"), 

821 "placeholder": lazy_gettext("https://www.my-journal.com/about#licensing"), 

822 }, 

823 "widgets": [ 

824 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

825 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

826 ] 

827 } 

828 

829 # ~~->$ LicenseDisplay:FormField~~ 

830 LICENSE_DISPLAY = { 

831 "name": "license_display", 

832 "label": lazy_gettext("Does the journal embed and/or display licensing information in its articles?"), 

833 "input": "radio", 

834 "options": [ 

835 {"display": lazy_gettext("Yes"), "value": "y", "subfields": ["license_display_example_url"]}, 

836 {"display": lazy_gettext("No"), "value": "n"} 

837 ], 

838 "help": { 

839 "long_help": [lazy_gettext("It is recommended that licensing information is included in full-text articles " 

840 "but it is not required for inclusion. " 

841 "Answer <strong>Yes</strong> if licensing is displayed or " 

842 "embedded in all versions of each article.")] 

843 }, 

844 "validate": [ 

845 {"required": {"message": lazy_gettext("Select Yes or No")}} 

846 ] 

847 } 

848 

849 # ~~->$ LicenseDisplayExampleUrl:FormField~~ 

850 LICENSE_DISPLAY_EXAMPLE_URL = { 

851 "name": "license_display_example_url", 

852 "label": lazy_gettext("Recent article displaying or embedding a license in the full text"), 

853 "input": "text", 

854 "conditional": [ 

855 {"field": "license_display", "value": "y"} 

856 ], 

857 "help": { 

858 "short_help": lazy_gettext("Link to an example article"), 

859 "placeholder": "https://www.my-journal.com/articles/article-page" 

860 }, 

861 "validate": [ 

862 {"required_if": { 

863 "field": "license_display", 

864 "value": "y", 

865 "message": lazy_gettext("Enter the URL for any recent article that displays or embeds a license") 

866 } 

867 }, 

868 "is_url" # ~~^->IsURL:FormValidator~~ 

869 ], 

870 "widgets": [ 

871 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

872 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

873 ] 

874 } 

875 

876 # ~~->$ CopyrightAuthorRetails:FormField~~ 

877 COPYRIGHT_AUTHOR_RETAINS = { 

878 "name": "copyright_author_retains", 

879 "label": lazy_gettext("For all the licenses you have indicated above, do authors retain the copyright " 

880 "<b>and</b> full publishing rights without restrictions?"), 

881 "input": "radio", 

882 "options": [ 

883 {"display": lazy_gettext("Yes"), "value": "y"}, 

884 {"display": lazy_gettext("No"), "value": "n"} 

885 ], 

886 "validate": [ 

887 {"required": {"message": lazy_gettext("Select Yes or No")}} 

888 ], 

889 "help": { 

890 "long_help": [lazy_gettext("Answer <strong>No</strong> if authors transfer " 

891 "copyright or assign exclusive rights to the publisher" 

892 " (including commercial rights). <br/><br/> Answer " 

893 "<strong>Yes</strong> only if authors publishing " 

894 "under any license allowed by the journal " 

895 "retain all rights.")] 

896 } 

897 } 

898 

899 # ~~->$ CopyrightURL:FormField~~ 

900 COPYRIGHT_URL = { 

901 "name": "copyright_url", 

902 "label": lazy_gettext("Where can we find this information?"), 

903 "input": "text", 

904 "diff_table_context": lazy_gettext("Copyright terms"), 

905 "help": { 

906 "short_help": lazy_gettext("Link to the journal’s copyright terms") 

907 }, 

908 "placeholder": "https://www.my-journal.com/about#licensing", 

909 "validate": [ 

910 "is_url" # ~~^->IsURL:FormValidator~~ 

911 ], 

912 "widgets": [ 

913 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

914 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

915 ], 

916 "contexts": { 

917 "public": { 

918 "validate": [ 

919 {"required": {"message": lazy_gettext("Enter the URL for the journal’s <strong>copyright terms</strong> page")}}, 

920 "is_url" # ~~^->IsURL:FormValidator~~ 

921 ] 

922 }, 

923 "update_request": { 

924 "validate": [ 

925 "required", 

926 "is_url" # ~~^->IsURL:FormValidator~~ 

927 ] 

928 } 

929 } 

930 } 

931 

932 # ~~->$ ReviewProcess:FormField~~ 

933 REVIEW_PROCESS = { 

934 "name": "review_process", 

935 "label": lazy_gettext("DOAJ only accepts peer-reviewed journals. " 

936 "Which type(s) of peer review does this journal use?"), 

937 "input": "checkbox", 

938 "multiple": True, 

939 "options": [ 

940 {"display": lazy_gettext("Editorial review"), "value": "Editorial review"}, 

941 {"display": lazy_gettext("Single anonymous peer review"), "value": "Single anonymous peer review"}, 

942 {"display": lazy_gettext("Double anonymous peer review"), "value": "Double anonymous peer review"}, 

943 {"display": lazy_gettext("Triple anonymous peer review"), "value": "Triple anonymous peer review"}, 

944 {"display": lazy_gettext("Post-publication peer review"), "value": "Post-publication peer review"}, 

945 {"display": lazy_gettext("Open peer review"), "value": "Open peer review"}, 

946 {"display": lazy_gettext("Other"), "value": "other", "subfields": ["review_process_other"]} 

947 ], 

948 "help": { 

949 "long_help": [lazy_gettext("Enter all types of review used by the journal for " 

950 "research articles. Note that editorial review is " 

951 "only accepted for <a href='https://doaj.org/apply/guide/#arts-and-humanities-journals' target='_blank' rel='nofollow'>arts and humanities journals</a>." 

952 "For a detailed description of the peer review types, " 

953 "see <a href='https://docs.google.com/document/d/1ADiVPR7tY8a9JKr2VjFEXbNG7FIpz22nOPDDPfRzJxA/edit?tab=t.0' target='_blank' rel='nofollow'>this summary</a>.")], 

954 "doaj_criteria": lazy_gettext("Peer review must be carried out") 

955 }, 

956 "validate": [ 

957 {"required": {"message": lazy_gettext("Select <strong>at least one</strong> type of review process")}} 

958 ] 

959 } 

960 

961 # ~~->$ ReviewProcessOther:FormField~~ 

962 REVIEW_PROCESS_OTHER = { 

963 "name": "review_process_other", 

964 "label": lazy_gettext("Other peer review"), 

965 "input": "text", 

966 "help": { 

967 "placeholder": lazy_gettext("Other peer review") 

968 }, 

969 "conditional": [{"field": "review_process", "value": "other"}], 

970 "validate": [ 

971 {"required_if": { 

972 "field": "review_process", 

973 "value": "other", 

974 "message": lazy_gettext("Enter the name of another type of peer review") 

975 }}, 

976 {"not_value": { 

977 "value": "None", 

978 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

979 }}, # ~~^-> NotValue:FormValidator~~ 

980 {"forbidden_word": { 

981 "word": "blind", 

982 "message": lazy_gettext("Please use the structured options above to indicate the type of peer review used.") 

983 }} # ~~^-> ForbiddenWord:FormValidator~~ 

984 ], 

985 "widgets": [ 

986 "trim_whitespace" # ~~^-> TrimWhitespace:FormWidget~~ 

987 ] 

988 } 

989 

990 # ~~->$ ReviewURL:FormField~~ 

991 REVIEW_URL = { 

992 "name": "review_url", 

993 "label": lazy_gettext("Where can we find this information?"), 

994 "input": "text", 

995 "diff_table_context": lazy_gettext("Peer review policy"), 

996 "help": { 

997 "doaj_criteria": lazy_gettext("You must provide a URL"), 

998 "short_help": lazy_gettext("Link to the journal’s peer review policy") 

999 }, 

1000 "validate": [ 

1001 {"required": {"message": lazy_gettext("Enter the URL for the journal’s <strong>peer review policy</strong> page")}}, 

1002 "is_url" # ~~^->IsURL:FormValidator~~ 

1003 ], 

1004 "widgets": [ 

1005 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1006 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1007 ] 

1008 } 

1009 

1010 # ~~->$ OAStart:FormField~~ 

1011 OA_START = { 

1012 "name": "oa_start", 

1013 "label": lazy_gettext("When did the journal start to publish all content using an open license?"), 

1014 "input": "number", 

1015 "datatype": "integer", 

1016 "help": { 

1017 "long_help": [ 

1018 lazy_gettext("Please enter the year that the journal started to publish all content as true open access, according to DOAJ's <a href='https://blog.doaj.org/2020/11/17/what-does-doaj-define-as-open-access/' target='_blank' rel='nofollow'>definition</a>."), 

1019 lazy_gettext("For journals that have flipped to open access, enter the year that the journal flipped, not the original launch date of the journal."), 

1020 lazy_gettext("For journals that have made digitised backfiles freely available, enter the year that the journal started publishing as a fully open access title, not the date of the earliest free content.")] 

1021 }, 

1022 "validate": [ 

1023 {"required": {"message": lazy_gettext("Enter the Year (YYYY).")}}, 

1024 {"int_range": {"gte": app.config.get('MINIMAL_OA_START_DATE', 1900), "lte": dates.now().year}}, 

1025 {"year": { 

1026 "message": lazy_gettext("OA Start Date must be a year in the 4-digit format (eg. 1987) and must be greater than %(min_year)s", 

1027 min_year=app.config.get('MINIMAL_OA_START_DATE', 1900))}} 

1028 ], 

1029 "attr": { 

1030 "min": app.config.get('MINIMAL_OA_START_DATE', 1900), 

1031 "max": dates.now().year 

1032 } 

1033 } 

1034 

1035 # ~~->$ PlagiarismDetection:FormField~~ 

1036 PLAGIARISM_DETECTION = { 

1037 "name": "plagiarism_detection", 

1038 "label": lazy_gettext("Does the journal routinely screen article submissions for plagiarism?"), 

1039 "input": "radio", 

1040 "help": { 

1041 "long_help": [lazy_gettext("Screening for plagiarism is recommended, but is not" 

1042 " a requirement for inclusion in DOAJ. If the " 

1043 "journal does screen for plagiarism, state the " 

1044 "services(s) used on your website.")], 

1045 }, 

1046 "options": [ 

1047 {"display": lazy_gettext("Yes"), "value": "y"}, 

1048 {"display": lazy_gettext("No"), "value": "n"} 

1049 ], 

1050 "validate": [ 

1051 {"required": {"message": lazy_gettext("Select Yes or No")}} 

1052 ] 

1053 } 

1054 

1055 # ~~->$ PlagiarismURL:FormField~~ 

1056 PLAGIARISM_URL = { 

1057 "name": "plagiarism_url", 

1058 "label": lazy_gettext("Where can we find this information?"), 

1059 "diff_table_context": lazy_gettext("Plagiarism screening"), 

1060 "input": "text", 

1061 "conditional": [{"field": "plagiarism_detection", "value": "y"}], 

1062 "help": { 

1063 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1064 "placeholder": "https://www.my-journal.com/about#plagiarism", 

1065 "short_help": lazy_gettext("Link to the journal’s plagiarism policy"), 

1066 "long_help": [lazy_gettext("The page should state that the journal actively checks for plagiarism and explain how this " 

1067 "is done (including the name of any software or service used).")] 

1068 }, 

1069 "validate": [ 

1070 {"required_if": { 

1071 "field": "plagiarism_detection", 

1072 "value": "y", 

1073 "message": lazy_gettext("Enter the URL for the journal’s <strong>plagiarism policy</strong> page") 

1074 } 

1075 }, 

1076 "is_url" # ~~^->IsURL:FormValidator~~ 

1077 ], 

1078 "widgets": [ 

1079 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1080 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1081 ] 

1082 } 

1083 

1084 # ~~->$ AimsScopeURL:FormField~~ 

1085 AIMS_SCOPE_URL = { 

1086 "name": "aims_scope_url", 

1087 "label": lazy_gettext("Link to the journal’s <b>Aims & Scope</b>"), 

1088 "input": "text", 

1089 "help": { 

1090 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1091 "placeholder": "https://www.my-journal.com/about#aims" 

1092 }, 

1093 "validate": [ 

1094 {"required": {"message": lazy_gettext("Enter the URL for the journal’s <strong>Aims & Scope</strong> page")}}, 

1095 "is_url" # ~~^->IsURL:FormValidator~~ 

1096 ], 

1097 "widgets": [ 

1098 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1099 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1100 ] 

1101 } 

1102 

1103 # ~~->$ EditorialBoardURL:FormField~~ 

1104 EDITORIAL_BOARD_URL = { 

1105 "name": "editorial_board_url", 

1106 "label": lazy_gettext("Link to the journal’s <b>Editorial Board</b>"), 

1107 "input": "text", 

1108 "help": { 

1109 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1110 "placeholder": "https://www.my-journal.com/about#board" 

1111 }, 

1112 "validate": [ 

1113 {"required": {"message": lazy_gettext("Enter the URL for the journal’s <strong>Editorial Board</strong> page")}}, 

1114 "is_url" # ~~^->IsURL:FormValidator~~ 

1115 ], 

1116 "widgets": [ 

1117 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1118 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1119 ] 

1120 } 

1121 

1122 # ~~->$ AuthorInstructionsURL:FormField~~ 

1123 AUTHOR_INSTRUCTIONS_URL = { 

1124 "name": "author_instructions_url", 

1125 "label": lazy_gettext("Link to the journal’s <b>Instructions for Authors</b>"), 

1126 "input": "text", 

1127 "help": { 

1128 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1129 "placeholder": "https://www.my-journal.com/for_authors" 

1130 }, 

1131 "validate": [ 

1132 {"required": {"message": lazy_gettext("Enter the URL for the journal’s <strong>Instructions for Authors</strong> page")}}, 

1133 "is_url" # ~~^->IsURL:FormValidator~~ 

1134 ], 

1135 "widgets": [ 

1136 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1137 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1138 ] 

1139 } 

1140 

1141 # ~~->$ PublicationTimeWeeks:FormField~~ 

1142 PUBLICATION_TIME_WEEKS = { 

1143 "name": "publication_time_weeks", 

1144 "label": lazy_gettext("Average number of <strong>weeks</strong> between article submission & publication"), 

1145 "input": "number", 

1146 "datatype": "integer", 

1147 "validate": [ 

1148 {"required": {"message": lazy_gettext("Enter an average number of weeks")}}, 

1149 {"int_range": {"gte": 1, "lte": 100}} 

1150 ], 

1151 "attr": { 

1152 "min": "1", 

1153 "max": "100" 

1154 } 

1155 } 

1156 

1157 # ~~->$ APC:FormField~~ 

1158 APC = { 

1159 "name": "apc", 

1160 "label": lazy_gettext("Does the journal charge fees for publishing an article (APCs)?"), 

1161 "input": "radio", 

1162 "options": [ 

1163 {"display": lazy_gettext("Yes"), "value": "y", "subfields": ["apc_charges"]}, 

1164 {"display": lazy_gettext("No"), "value": "n"} 

1165 ], 

1166 "help": { 

1167 "long_help": [lazy_gettext("Publication fees are sometimes called " 

1168 "article processing charges (APCs). You should answer" 

1169 " Yes if any fee is required from the author for " 

1170 "publishing their paper.")], 

1171 "doaj_criteria": lazy_gettext("You must tell us about any APCs") 

1172 }, 

1173 "validate": [ 

1174 {"required": {"message": lazy_gettext("Select Yes or No")}} 

1175 ] 

1176 } 

1177 

1178 # ~~->$ APCCharges:FormField~~ 

1179 APC_CHARGES = { 

1180 "name": "apc_charges", 

1181 "input": "group", 

1182 "label": lazy_gettext("Highest fee charged"), 

1183 "repeatable": { 

1184 "minimum": 1, 

1185 "initial": 5 

1186 }, 

1187 "conditional": [ 

1188 {"field": "apc", "value": "y"} 

1189 ], 

1190 "help": { 

1191 "long_help": [lazy_gettext("If the journal charges a range of fees for " 

1192 "the publication of an article, enter the highest fee. " 

1193 "If the fee can be paid in more than one currency, " 

1194 "you may list them here.")] 

1195 }, 

1196 "subfields": [ 

1197 "apc_currency", 

1198 "apc_max" 

1199 ], 

1200 "template": templates.AF_LIST, 

1201 "entry_template": templates.AF_ENTRY_GROUP_HORIZONTAL, 

1202 "widgets": [ 

1203 "multiple_field" 

1204 ] 

1205 } 

1206 

1207 # ~~->$ APCCurrency:FormField~~ 

1208 APC_CURRENCY = { 

1209 "subfield": True, 

1210 "group": "apc_charges", 

1211 "name": "apc_currency", 

1212 "input": "select", 

1213 "options_fn": "iso_currency_list", 

1214 "default": "", 

1215 "help": { 

1216 "placeholder": "Currency" 

1217 }, 

1218 "widgets": [ 

1219 {"select": {}} 

1220 ], 

1221 "attr": { 

1222 "class": "input-xlarge" 

1223 }, 

1224 "validate": [ 

1225 { 

1226 "required_if": { 

1227 "field": "apc", 

1228 "value": "y", 

1229 "message": lazy_gettext("Enter the currency or currencies for the journal’s publishing fees") 

1230 } 

1231 }, 

1232 "current_iso_currency" 

1233 ] 

1234 } 

1235 

1236 # ~~->$ APCMax:FormField~~ 

1237 APC_MAX = { 

1238 "subfield": True, 

1239 "group": "apc_charges", 

1240 "name": "apc_max", 

1241 "input": "number", 

1242 "datatype": "integer", 

1243 "help": { 

1244 "placeholder": lazy_gettext("Highest fee charged") 

1245 }, 

1246 "validate": [ 

1247 { 

1248 "required_if": { 

1249 "field": "apc", 

1250 "value": "y", 

1251 "message": lazy_gettext("Enter the value of the highest publishing fee the journal has charged") 

1252 } 

1253 } 

1254 ], 

1255 "attr": { 

1256 "min": "1" 

1257 } 

1258 } 

1259 

1260 # ~~->$ APCURL:FormField~~ 

1261 APC_URL = { 

1262 "name": "apc_url", 

1263 "label": lazy_gettext("Where can we find this information?"), 

1264 "diff_table_context": lazy_gettext("Publication fees"), 

1265 "input": "text", 

1266 "help": { 

1267 "short_help": lazy_gettext("Link to the page where this is stated. The page " 

1268 "must declare <b>whether or not</b> there is a fee " 

1269 "to publish an article in the journal."), 

1270 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1271 "placeholder": "https://www.my-journal.com/about#apc" 

1272 }, 

1273 "validate": [ 

1274 {"required": { 

1275 "message": lazy_gettext("Enter the URL for the journal’s <strong>publication fees</strong> information page")}}, 

1276 "is_url" # ~~^->IsURL:FormValidator~~ 

1277 ], 

1278 "widgets": [ 

1279 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1280 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1281 ] 

1282 } 

1283 

1284 # ~~->$ HasWaiver:FormField~~ 

1285 HAS_WAIVER = { 

1286 "name": "has_waiver", 

1287 "label": lazy_gettext("Does the journal provide a waiver or discount " 

1288 "on publication fees for authors?"), 

1289 "input": "radio", 

1290 "options": [ 

1291 {"display": lazy_gettext("Yes"), "value": "y", "subfields": ["waiver_url"]}, 

1292 {"display": lazy_gettext("No"), "value": "n"} 

1293 ], 

1294 "help": { 

1295 "long_help": [lazy_gettext("Answer <strong>Yes</strong> if the journal provides" 

1296 " publication fee waivers for authors from " 

1297 "low-income economies, discounts for authors from " 

1298 "lower middle-income economies, and/or waivers and " 

1299 "discounts for other authors with " 

1300 "demonstrable needs.")] 

1301 }, 

1302 "validate": [ 

1303 {"required": {"message": lazy_gettext("Select Yes or No")}} 

1304 ] 

1305 } 

1306 

1307 # ~~->$ WaiverURL:FormField~~ 

1308 WAIVER_URL = { 

1309 "name": "waiver_url", 

1310 "label": lazy_gettext("Where can we find this information?"), 

1311 "input": "text", 

1312 "diff_table_context": lazy_gettext("Publication fee waiver"), 

1313 "conditional": [ 

1314 {"field": "has_waiver", "value": "y"} 

1315 ], 

1316 "help": { 

1317 "short_help": lazy_gettext("Link to the journal’s waiver information."), 

1318 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1319 "placeholder": "https://www.my-journal.com/about#waiver" 

1320 }, 

1321 "validate": [ 

1322 {"required_if": { 

1323 "field": "has_waiver", 

1324 "value": "y", 

1325 "message": lazy_gettext("Enter the URL for the journal’s <strong>waiver information</strong> page") 

1326 } 

1327 }, 

1328 "is_url" # ~~^->IsURL:FormValidator~~ 

1329 ], 

1330 "widgets": [ 

1331 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1332 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1333 ] 

1334 } 

1335 

1336 # ~~->$ HasOtherCharges:FormField~~ 

1337 HAS_OTHER_CHARGES = { 

1338 "name": "has_other_charges", 

1339 "label": lazy_gettext("Does the journal charge any other fees to authors?"), 

1340 "input": "radio", 

1341 "options": [ 

1342 {"display": lazy_gettext("Yes"), "value": "y", "subfields": ["other_charges_url"]}, 

1343 {"display": lazy_gettext("No"), "value": "n"} 

1344 ], 

1345 "help": { 

1346 "long_help": [lazy_gettext("Declare all other charges: editorial processing charges, language editing fees, " 

1347 "colour charges, submission fees, page charges, membership fees, print subscription costs, " 

1348 "other supplementary charges")], 

1349 "doaj_criteria": lazy_gettext("You must declare any other charges if they exist") 

1350 }, 

1351 "validate": [ 

1352 {"required": {"message": lazy_gettext("Select Yes or No")}} 

1353 ] 

1354 } 

1355 

1356 # ~~->$ OtherChargesURL:FormField~~ 

1357 OTHER_CHARGES_URL = { 

1358 "name": "other_charges_url", 

1359 "label": lazy_gettext("Where can we find this information?"), 

1360 "input": "text", 

1361 "diff_table_context": lazy_gettext("Other fees"), 

1362 "conditional": [ 

1363 {"field": "has_other_charges", "value": "y"} 

1364 ], 

1365 "help": { 

1366 "short_help": lazy_gettext("Link to the journal’s fees information"), 

1367 "doaj_criteria": lazy_gettext("You must provide a URL") 

1368 }, 

1369 "validate": [ 

1370 {"required_if": { 

1371 "field": "has_other_charges", 

1372 "value": "y", 

1373 "message": lazy_gettext("Enter the URL for the journal’s <strong>fees<strong> information page") 

1374 } 

1375 }, 

1376 "is_url" # ~~^->IsURL:FormValidator~~ 

1377 ], 

1378 "widgets": [ 

1379 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1380 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1381 ] 

1382 } 

1383 

1384 # ~~->$ PreservationService:FormField~~ 

1385 PRESERVATION_SERVICE = { 

1386 "name": "preservation_service", 

1387 "label": lazy_gettext("Long-term preservation service(s) where the journal is currently archived"), 

1388 "input": "checkbox", 

1389 "multiple": True, 

1390 "options": [ 

1391 {"display": lazy_gettext("CINES"), "value": "CINES", "subfields": ["preservation_service_url"]}, 

1392 {"display": lazy_gettext("CLOCKSS"), "value": "CLOCKSS", "subfields": ["preservation_service_url"]}, 

1393 {"display": lazy_gettext("LOCKSS"), "value": "LOCKSS", "subfields": ["preservation_service_url"]}, 

1394 {"display": lazy_gettext("Internet Archive"), "value": "Internet Archive", "subfields": ["preservation_service_url"]}, 

1395 {"display": lazy_gettext("PKP PN"), "value": "PKP PN", "subfields": ["preservation_service_url"]}, 

1396 {"display": lazy_gettext("PubMed Central (PMC)"), "value": "PMC", "subfields": ["preservation_service_url"]}, 

1397 {"display": lazy_gettext("Portico"), "value": "Portico", "subfields": ["preservation_service_url"]}, 

1398 {"display": lazy_gettext("A national library"), "value": "national_library", 

1399 "subfields": ["preservation_service_library", "preservation_service_url"]}, 

1400 {"display": lazy_gettext("Other"), "value": "other", 

1401 "subfields": ["preservation_service_other", "preservation_service_url"]}, 

1402 {"display": lazy_gettext(HTMLString("<em>The journal content isn’t archived with a long-term preservation service</em>")), 

1403 "value": "none", "exclusive": True} 

1404 ], 

1405 "help": { 

1406 "long_help": [ 

1407 lazy_gettext("Content must be actively deposited in each of the options you choose. " 

1408 "If the journal is registered with a service but archiving is not yet active," 

1409 " choose <em>The journal content isn’t archived with a long-term preservation service</em>."), 

1410 lazy_gettext("PubMed Central covers PMC U.S.A. and EuropePMC(Wellcome Trust).")] 

1411 }, 

1412 "validate": [ 

1413 {"required": {"message": lazy_gettext("Select <strong>at least one</strong> option")}} 

1414 ], 

1415 "contexts": { 

1416 "admin": { 

1417 "widgets": [ 

1418 "autocheck", # ~~^-> Autocheck:FormWidget~~ 

1419 ] 

1420 } 

1421 } 

1422 } 

1423 

1424 # ~~->$ PreservationServiceLibrary:FormField~~ 

1425 PRESERVATION_SERVICE_LIBRARY = { 

1426 "name": "preservation_service_library", 

1427 "label": lazy_gettext("A national library"), 

1428 "input": "text", 

1429 "repeatable": { 

1430 "minimum": 1, 

1431 "initial": 2 

1432 }, 

1433 "help": { 

1434 "short_help": lazy_gettext("Name of national library") 

1435 }, 

1436 "conditional": [{"field": "preservation_service", "value": "national_library"}], 

1437 "validate": [ 

1438 {"required_if": { 

1439 "field": "preservation_service", 

1440 "value": "national_library", 

1441 "message": lazy_gettext("Enter the name(s) of the national library or libraries where the journal is archived") 

1442 }}, 

1443 {"not_value": { 

1444 "value": "None", 

1445 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

1446 }} # ~~^-> NotValue:FormValidator~~ 

1447 ], 

1448 "widgets": [ 

1449 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1450 "multiple_field" 

1451 ], 

1452 "attr": { 

1453 "class": "input-xlarge unstyled-list" 

1454 } 

1455 } 

1456 

1457 # ~~->$ PreservationServiceOther:FormField~~ 

1458 PRESERVATION_SERVICE_OTHER = { 

1459 "name": "preservation_service_other", 

1460 "label": lazy_gettext("Other archiving policy:"), 

1461 "input": "text", 

1462 "conditional": [{"field": "preservation_service", "value": "other"}], 

1463 "validate": [ 

1464 {"required_if": { 

1465 "field": "preservation_service", 

1466 "value": "other", 

1467 "message": lazy_gettext("Enter the name of another archiving policy") 

1468 }}, 

1469 {"not_value": { 

1470 "value": "None", 

1471 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

1472 }} # ~~^-> NotValue:FormValidator~~ 

1473 ], 

1474 "widgets": [ 

1475 "trim_whitespace" # ~~^-> TrimWhitespace:FormWidget~~ 

1476 ] 

1477 } 

1478 

1479 # ~~->$ PreservationServiceURL:FormField~~ 

1480 PRESERVATION_SERVICE_URL = { 

1481 "name": "preservation_service_url", 

1482 "label": lazy_gettext("Where can we find this information?"), 

1483 "input": "text", 

1484 "diff_table_context": "Archiving policy", 

1485 "help": { 

1486 "short_help": lazy_gettext("Link to the preservation and archiving information"), 

1487 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1488 "placeholder": "https://www.my-journal.com/about#archiving" 

1489 }, 

1490 "conditional": [ 

1491 {"field": "preservation_service", "value": "CINES"}, 

1492 {"field": "preservation_service", "value": "CLOCKSS"}, 

1493 {"field": "preservation_service", "value": "LOCKSS"}, 

1494 {"field": "preservation_service", "value": "Internet Archive"}, 

1495 {"field": "preservation_service", "value": "PKP PN"}, 

1496 {"field": "preservation_service", "value": "PMC"}, 

1497 {"field": "preservation_service", "value": "Portico"}, 

1498 {"field": "preservation_service", "value": "national_library"}, 

1499 {"field": "preservation_service", "value": "other"} 

1500 ], 

1501 "validate": [ 

1502 { 

1503 "required_if": { 

1504 "field": "preservation_service", 

1505 "value": [ 

1506 "CINES", 

1507 "CLOCKSS", 

1508 "LOCKSS", 

1509 "Internet Archive", 

1510 "PKP PN", 

1511 "PMC", 

1512 "Portico", 

1513 "national_library", 

1514 "other" 

1515 ] 

1516 } 

1517 }, 

1518 "is_url" # ~~^->IsURL:FormValidator~~ 

1519 ], 

1520 "widgets": [ 

1521 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1522 "clickable_url" # ~~^-> ClickableURL:FormWidget~~ 

1523 ] 

1524 } 

1525 

1526 # ~~->$ DepositPolicy:FormField~~ 

1527 DEPOSIT_POLICY = { 

1528 "name": "deposit_policy", 

1529 "label": lazy_gettext("Does the journal have a policy allowing authors to deposit versions of their work in an " 

1530 "institutional or other repository of their choice? Where is this policy recorded?"), 

1531 "input": "checkbox", 

1532 "multiple": True, 

1533 "options": [ 

1534 {"display": lazy_gettext("Diadorim"), "value": "Diadorim", "subfields": ["deposit_policy_url"]}, 

1535 {"display": lazy_gettext("Dulcinea"), "value": "Dulcinea", "subfields": ["deposit_policy_url"]}, 

1536 {"display": lazy_gettext("Mir@bel"), "value": "Mir@bel", "subfields": ["deposit_policy_url"]}, 

1537 {"display": lazy_gettext("Open Policy Finder"), "value": "Open Policy Finder", "subfields": ["deposit_policy_url"]}, 

1538 {"display": lazy_gettext("Other (including publisher’s own site)"), "value": "other", 

1539 "subfields": ["deposit_policy_other", "deposit_policy_url"]}, 

1540 {"display": lazy_gettext(HTMLString("<em>The journal has no repository policy</em>")), "value": "none", "exclusive": True} 

1541 ], 

1542 "help": { 

1543 "long_help": [lazy_gettext("Many authors wish to deposit a copy of their paper in an institutional or other repository " 

1544 "of their choice. What is the journal’s policy for this?"), 

1545 lazy_gettext("""You should state your policy about the different versions of the paper: 

1546 <ul style='list-style-type: none;'> 

1547 <li>Submitted version</li> 

1548 <li>Accepted version (Author Accepted Manuscript)</li> 

1549 <li>Published version (Version of Record)</li> 

1550 </ul>""") 

1551 ]}, 

1552 "validate": [ 

1553 {"required": {"message": lazy_gettext("Select <strong>at least one</strong> option")}} 

1554 ] 

1555 } 

1556 

1557 # ~~->$ DepositPolicyOther:FormField~~ 

1558 DEPOSIT_POLICY_OTHER = { 

1559 "name": "deposit_policy_other", 

1560 "label": lazy_gettext("Name of other website where policy is registered"), 

1561 "input": "text", 

1562 "conditional": [{"field": "deposit_policy", "value": "other"}], 

1563 "validate": [ 

1564 {"required_if": { 

1565 "field": "deposit_policy", 

1566 "value": "other", 

1567 "message": lazy_gettext("Enter the name of another repository policy") 

1568 }}, 

1569 {"not_value": { 

1570 "value": "None", 

1571 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

1572 }} # ~~^-> NotValue:FormValidator~~ 

1573 ], 

1574 "widgets": [ 

1575 "trim_whitespace" # ~~^-> TrimWhitespace:FormWidget~~ 

1576 ] 

1577 } 

1578 

1579 # ~~->$ DepositPolicyURL:FormField~~ 

1580 DEPOSIT_POLICY_URL = { 

1581 "name": "deposit_policy_url", 

1582 "label": lazy_gettext("Where can we find this information?"), 

1583 "input": "text", 

1584 "diff_table_context": "Repository policy", 

1585 "conditional": [{"field": "deposit_policy", "value": "Diadorim"}, 

1586 {"field": "deposit_policy", "value": "Dulcinea"}, 

1587 {"field": "deposit_policy", "value": "Mir@bel"}, 

1588 {"field": "deposit_policy", "value": "Open Policy Finder"}, 

1589 {"field": "deposit_policy", "value": "other"}], 

1590 "help": { 

1591 "doaj_criteria": lazy_gettext("You must provide a URL"), 

1592 "short_help": lazy_gettext("Provide the link to the policy in the selected directory. Or select 'Other' and provide a link to the information on your website."), 

1593 "placeholder": "https://www.my-journal.com/about#repository_policy" 

1594 }, 

1595 "validate": [ 

1596 "is_url" # ~~^->IsURL:FormValidator~~ 

1597 ], 

1598 "widgets": [ 

1599 "trim_whitespace", # ~~^-> TrimWhitespace:FormWidget~~ 

1600 "clickable_url", # ~~^-> ClickableURL:FormWidget~~ 

1601 ], 

1602 "contexts": { 

1603 "public": { 

1604 "validate": [ 

1605 { 

1606 "required_if": { 

1607 "field": "deposit_policy", 

1608 "value": [ 

1609 "Diadorim", 

1610 "Dulcinea", 

1611 "Mir@bel", 

1612 "Open Policy Finder", 

1613 "other" 

1614 ] 

1615 } 

1616 }, 

1617 "is_url" # ~~^->IsURL:FormValidator~~ 

1618 ] 

1619 }, 

1620 "update_request": { 

1621 "validate": [ 

1622 { 

1623 "required_if": { 

1624 "field": "deposit_policy", 

1625 "value": [ 

1626 "Diadorim", 

1627 "Dulcinea", 

1628 "Mir@bel", 

1629 "Open Policy Finder", 

1630 "other" 

1631 ] 

1632 } 

1633 }, 

1634 "is_url" # ~~^->IsURL:FormValidator~~ 

1635 ] 

1636 } 

1637 } 

1638 } 

1639 

1640 # ~~->$ PersistentIdentifiers:FormField~~ 

1641 PERSISTENT_IDENTIFIERS = { 

1642 "name": "persistent_identifiers", 

1643 "label": lazy_gettext("Persistent article identifiers used by the journal"), 

1644 "input": "checkbox", 

1645 "multiple": True, 

1646 "hint": lazy_gettext("Select at least one"), 

1647 "options": [ 

1648 {"display": lazy_gettext("DOIs"), "value": "DOI"}, 

1649 {"display": lazy_gettext("ARKs"), "value": "ARK"}, 

1650 {"display": lazy_gettext("Handles"), "value": "Handles"}, 

1651 {"display": lazy_gettext("PURLs"), "value": "PURL"}, 

1652 {"display": lazy_gettext("Other"), "value": "other", "subfields": ["persistent_identifiers_other"]}, 

1653 {"display": lazy_gettext(HTMLString("<em>The journal does not use persistent article identifiers</em>")), "value": "none", 

1654 "exclusive": True} 

1655 ], 

1656 "help": { 

1657 "long_help": [ 

1658 lazy_gettext("A persistent article identifier (PID) is used to find the article no matter where it is located. The most common type of PID is the digital object identifier (DOI)."), 

1659 lazy_gettext("<a href='https://en.wikipedia.org/wiki/Persistent_identifier' target='_blank' rel='noopener'>Read more about PIDs.</a>")], 

1660 }, 

1661 "validate": [ 

1662 {"required": {"message": lazy_gettext("Select <strong>at least one</strong> option")}} 

1663 ] 

1664 } 

1665 

1666 # ~~->$ PersistentIdentifiersOther:FormField~~ 

1667 PERSISTENT_IDENTIFIERS_OTHER = { 

1668 "name": "persistent_identifiers_other", 

1669 "label": lazy_gettext("Other identifier"), 

1670 "input": "text", 

1671 "conditional": [{"field": "persistent_identifiers", "value": "other"}], 

1672 "validate": [ 

1673 {"required_if": { 

1674 "field": "persistent_identifiers", 

1675 "value": "other", 

1676 "message": lazy_gettext("Enter the name of another type of identifier") 

1677 }}, 

1678 {"not_value": { 

1679 "value": "None", 

1680 "message": lazy_gettext("'None' is not a valid answer for this question. Leave blank.") 

1681 }} # ~~^-> NotValue:FormValidator~~ 

1682 ], 

1683 "widgets": [ 

1684 "trim_whitespace" # ~~^-> TrimWhitespace:FormWidget~~ 

1685 ] 

1686 } 

1687 

1688 ####################################### 

1689 ## Editorial fields 

1690 

1691 S2O = { 

1692 "name": "s2o", 

1693 "label": lazy_gettext("Subscribe to Open"), 

1694 "input": "checkbox", 

1695 "help": { 

1696 "long_help": [ 

1697 lazy_gettext("Is the journal part of the <a href='https://subscribetoopencommunity.org/' target='_blank' rel='noopener'>" 

1698 "Subscribe to Open</a> initiative?")], 

1699 } 

1700 } 

1701 

1702 MIRROR = { 

1703 "name": "mirror", 

1704 "label": "Mirror Journal", 

1705 "input": "checkbox", 

1706 "help": { 

1707 "long_help": ["Is the journal a Mirror Journal?"] 

1708 } 

1709 } 

1710 

1711 OJC = { 

1712 "name": "ojc", 

1713 "label": "Open Journals Collective", 

1714 "input": "checkbox", 

1715 "help": { 

1716 "long_help": [ 

1717 "Is the journal part of the <a href='https://openjournalscollective.org/' target='_blank' rel='noopener'>" 

1718 "Open Journals Collective</a>?"], 

1719 } 

1720 } 

1721 

1722 # FIXME: this probably shouldn't be in the admin form fieldsets, rather its own separate form 

1723 # ~~->$ QuickReject:FormField~~ 

1724 QUICK_REJECT = { 

1725 "name": "quick_reject", 

1726 "label": lazy_gettext("Reason for rejection"), 

1727 "input": "select", 

1728 "options_fn": "quick_reject" 

1729 } 

1730 

1731 # ~~->$ QuickRejectDetails:FormField~~ 

1732 QUICK_REJECT_DETAILS = { 

1733 "name": "quick_reject_details", 

1734 "label": lazy_gettext("Additional info"), 

1735 "input": "textarea", 

1736 "help": { 

1737 "long_help": [lazy_gettext("The selected reason for rejection, and any additional information you include, " 

1738 "are sent to the journal contact with the rejection email.")] 

1739 }, 

1740 "validate": [ 

1741 {"required_if": {"field": "quick_reject", "value": "other"}} 

1742 ], 

1743 } 

1744 

1745 # ~~->$ Owner:FormField~~ 

1746 OWNER = { 

1747 "name": "owner", 

1748 "label": lazy_gettext("DOAJ Account"), 

1749 "input": "text", 

1750 "validate": [ 

1751 "reserved_usernames", 

1752 "owner_exists" 

1753 ], 

1754 "widgets": [ 

1755 {"autocomplete": {"type": "account", "field": "id", "include": False}}, # ~~^-> Autocomplete:FormWidget~~ 

1756 "clickable_owner" 

1757 ], 

1758 "contexts": { 

1759 "associate_editor": { 

1760 "validate": [ 

1761 {"required": {"message": lazy_gettext("You must confirm the account id")}}, 

1762 "reserved_usernames", 

1763 "owner_exists" 

1764 ] 

1765 } 

1766 } 

1767 } 

1768 

1769 # ~~->$ ApplicationStatus:FormField~~ 

1770 APPLICATION_STATUS = { 

1771 "name": "application_status", 

1772 "label": lazy_gettext("Change status"), 

1773 "input": "select", 

1774 "options_fn": "application_statuses", 

1775 "validate": [ 

1776 "required" 

1777 ], 

1778 "help": { 

1779 "update_requests_diff": False, 

1780 "render_error_box": False 

1781 }, 

1782 "disabled": "application_status_disabled", 

1783 "contexts": { 

1784 "associate_editor": { 

1785 "help": { 

1786 "render_error_box": False, 

1787 "short_help": lazy_gettext("Set the status to 'In Progress' to signal to the applicant that you have started your review." 

1788 "Set the status to 'Completed' to alert the Editor that you have completed your review."), 

1789 "update_requests_diff": False 

1790 } 

1791 }, 

1792 "editor": { 

1793 "help": { 

1794 "render_error_box": False, 

1795 "short_help": lazy_gettext("Revert the status to 'In Progress' to signal to the Associate Editor that further work is needed." 

1796 "Set the status to 'Ready' to alert the Managing Editor that you have completed your review."), 

1797 "update_requests_diff": False 

1798 } 

1799 } 

1800 }, 

1801 "widgets": [ 

1802 # When Accepted selected display. 'This journal is currently assigned to its applicant account XXXXXX. Is this the correct account for this journal?' 

1803 "owner_review" 

1804 ] 

1805 } 

1806 

1807 # ~~->$ EditorGroup:FormField~~ 

1808 EDITOR_GROUP = { 

1809 "name": "editor_group", 

1810 "label": lazy_gettext("Group"), 

1811 "input": "text", 

1812 "widgets": [ 

1813 {"autocomplete": {"type": "editor_group", "field": "name", "include": False}} 

1814 # ~~^-> Autocomplete:FormWidget~~ 

1815 ], 

1816 "contexts": { 

1817 "editor": { 

1818 "disabled": True 

1819 }, 

1820 "admin": { 

1821 "widgets": [ 

1822 {"autocomplete": {"type": "editor_group", "field": "name", "include": False}}, 

1823 # ~~^-> Autocomplete:FormWidget~~ 

1824 {"load_editors": {"field": "editor"}} 

1825 ] 

1826 } 

1827 } 

1828 } 

1829 

1830 # ~~->$ Editor:FormField~~ 

1831 EDITOR = { 

1832 "name": "editor", 

1833 "label": lazy_gettext("Individual"), 

1834 "input": "select", 

1835 "options_fn": "editor_choices", 

1836 "default": "", 

1837 "validate": [ 

1838 {"group_member": {"group_field": "editor_group"}} 

1839 ], 

1840 "help": { 

1841 "render_error_box": False 

1842 } 

1843 } 

1844 

1845 # ~~->$ DiscontinuedDate:FormField~~ 

1846 DISCONTINUED_DATE = { 

1847 "name": "discontinued_date", 

1848 "label": lazy_gettext("Discontinued on"), 

1849 "input": "text", 

1850 "validate": [ 

1851 {"bigenddate": {"message": lazy_gettext("Date must be a big-end formatted date (e.g. 2020-11-23)")}}, 

1852 { 

1853 "not_if": { 

1854 "fields": [ 

1855 {"field": "continues"}, 

1856 {"field": "continued_by"} 

1857 ], 

1858 "message": lazy_gettext("You cannot enter both a discontinued date and continuation information.") 

1859 } 

1860 } 

1861 ], 

1862 "help": { 

1863 "short_help": lazy_gettext("Please enter the discontinued date in the form YYYY-MM-DD (e.g. 2020-11-23). " 

1864 "If the day of the month is not known, please use '01' (e.g. 2020-11-01)"), 

1865 "render_error_box": False 

1866 } 

1867 } 

1868 

1869 # ~~->$ Continues:FormField~~ 

1870 CONTINUES = { 

1871 "name": "continues", 

1872 "label": lazy_gettext("Continues an <strong>older</strong> journal with the ISSN(s)"), 

1873 "input": "taglist", 

1874 "validate": [ 

1875 {"is_issn_list": {"message": lazy_gettext("This is not a valid ISSN")}}, # ~~^-> IsISSN:FormValidator~~ 

1876 {"different_to": {"field": "continued_by", 

1877 "message": lazy_gettext("The ISSN provided in both fields must be different. Please make sure to enter the ISSN of an older journal for the first field and the ISSN of a newer journal for the second field. They cannot be the same.")}}, 

1878 # ~~^-> DifferetTo:FormValidator~~ 

1879 { 

1880 "not_if": { 

1881 "fields": [{"field": "discontinued_date"}], 

1882 "message": lazy_gettext("You cannot enter both continuation information and a discontinued date") 

1883 } 

1884 } 

1885 ], 

1886 "widgets": [ 

1887 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

1888 "full_contents", # ~~^->FullContents:FormWidget~~ 

1889 "tagentry" # ~~-> TagEntry:FormWidget~~ 

1890 ], 

1891 "help": { 

1892 "short_help": lazy_gettext("Enter the ISSN(s) of the previous title(s) of this journal."), 

1893 "render_error_box": False 

1894 } 

1895 } 

1896 

1897 # ~~->$ ContinuedBy:FormField~~ 

1898 CONTINUED_BY = { 

1899 "name": "continued_by", 

1900 "label": lazy_gettext("Continued by a <strong>newer</strong> journal with the ISSN(s)"), 

1901 "input": "taglist", 

1902 "validate": [ 

1903 {"is_issn_list": {"message": lazy_gettext("This is not a valid ISSN")}}, # ~~^-> IsISSN:FormValidator~~ 

1904 {"different_to": {"field": "continues", 

1905 "message": lazy_gettext("The ISSN provided in both fields must be different. Please make sure to enter the ISSN of an older journal for the first field and the ISSN of a newer journal for the second field. They cannot be the same.")}}, 

1906 # ~~^-> DifferetTo:FormValidator~~ 

1907 { 

1908 "not_if": { 

1909 "fields": [{"field": "discontinued_date"}], 

1910 "message": lazy_gettext("You cannot enter both continuation information and a discontinued date") 

1911 } 

1912 } 

1913 ], 

1914 "help": { 

1915 "short_help": lazy_gettext("Enter the ISSN(s) of the later title(s) that continue this publication."), 

1916 "render_error_box": False 

1917 }, 

1918 "widgets": [ 

1919 "click_to_copy", # ~~^-> ClickToCopy:FormWidget~~ 

1920 "full_contents", # ~~^->FullContents:FormWidget~~ 

1921 "tagentry" # ~~-> TagEntry:FormWidget~~ 

1922 ] 

1923 } 

1924 

1925 # ~~->$ Subject:FormField~~ 

1926 SUBJECT = { 

1927 "name": "subject", 

1928 "label": lazy_gettext("Assign one or a maximum of two subject classifications"), 

1929 "input": "taglist", 

1930 "help": { 

1931 "short_help": lazy_gettext("Selecting a subject will not automatically select its sub-categories"), 

1932 "render_error_box": False, 

1933 }, 

1934 "validate": [ 

1935 {"required_if": { 

1936 "field": "application_status", 

1937 "value": [ 

1938 constants.APPLICATION_STATUS_READY, 

1939 constants.APPLICATION_STATUS_COMPLETED, 

1940 constants.APPLICATION_STATUS_ACCEPTED 

1941 ], 

1942 "message": lazy_gettext("This field is required when setting the Application Status to %(y)s, %(z)s or %(a)s", 

1943 y=constants.APPLICATION_STATUS_READY, 

1944 z=constants.APPLICATION_STATUS_COMPLETED, 

1945 a=constants.APPLICATION_STATUS_ACCEPTED 

1946 ) 

1947 } 

1948 } 

1949 ], 

1950 "widgets": [ 

1951 "subject_tree" 

1952 ], 

1953 "contexts": { 

1954 "associate_editor": { 

1955 "validate": [ 

1956 "required" 

1957 ] 

1958 } 

1959 } 

1960 } 

1961 

1962 # ~~->$ Notes:FormField~~ 

1963 NOTES = { 

1964 "name": "notes", 

1965 "input": "group", 

1966 "label": lazy_gettext("Notes"), 

1967 "repeatable": { 

1968 "initial": 1, 

1969 "add_button_placement": "top" 

1970 }, 

1971 "subfields": [ 

1972 "note_author", 

1973 "note_date", 

1974 "note", 

1975 "note_id", 

1976 "note_author_id", 

1977 ], 

1978 "template": templates.AF_LIST, 

1979 "entry_template": templates.AF_ENTRY_GOUP, 

1980 "widgets": [ 

1981 {"infinite_repeat": {"enable_on_repeat": ["textarea"]}}, 

1982 "note_modal", 

1983 ], 

1984 "merge_disabled": "merge_disabled_notes", 

1985 } 

1986 

1987 # ~~->$ Note:FormField~~ 

1988 NOTE = { 

1989 "subfield": True, 

1990 "name": "note", 

1991 "group": "notes", 

1992 "input": "textarea", 

1993 "disabled": "disable_edit_note_except_editing_user", 

1994 } 

1995 

1996 # ~~->$ NoteAuthor:FormField~~ 

1997 NOTE_AUTHOR = { 

1998 "subfield": True, 

1999 "name": "note_author", 

2000 "group": "notes", 

2001 "input": "text", 

2002 "disabled": True 

2003 } 

2004 

2005 # ~~->$ NoteDate:FormField~~ 

2006 NOTE_DATE = { 

2007 "subfield": True, 

2008 "name": "note_date", 

2009 "group": "notes", 

2010 "input": "text", 

2011 "disabled": True 

2012 } 

2013 

2014 # ~~->$ NoteID:FormField~~ 

2015 NOTE_ID = { 

2016 "subfield": True, 

2017 "name": "note_id", 

2018 "group": "notes", 

2019 "input": "hidden" 

2020 } 

2021 

2022 # ~~->$ NoteAuthorID:FormField~~ 

2023 NOTE_AUTHOR_ID = { 

2024 "subfield": True, 

2025 "name": "note_author_id", 

2026 "group": "notes", 

2027 "input": "hidden" 

2028 } 

2029 

2030 FLAGS = { 

2031 "name": "flags", 

2032 "input": "group", 

2033 "label": "Flags", 

2034 "subfields": [ 

2035 "flag_setter", 

2036 "flag_created_date", 

2037 "flag_assignee", 

2038 "flag_deadline", 

2039 "flag_note", 

2040 "flag_note_id", 

2041 "flag_resolved" 

2042 ], 

2043 "template": templates.FLAG_ENTRY_GROUP, 

2044 "widgets": [ 

2045 "flag_manager" 

2046 ] 

2047 } 

2048 

2049 FLAG_RESOLVED = { 

2050 "subfield": True, 

2051 "name": "flag_resolved", 

2052 "group": "flags", 

2053 "input": "hidden", 

2054 } 

2055 

2056 # ~~->$ NoteAuthor:FormField~~ 

2057 FLAG_SETTER = { 

2058 "subfield": True, 

2059 "name": "flag_setter", 

2060 "group": "flags", 

2061 "input": "hidden", 

2062 } 

2063 

2064 # ~~->$ NoteDate:FormField~~ 

2065 FLAG_CREATED_DATE = { 

2066 "subfield": True, 

2067 "name": "flag_created_date", 

2068 "group": "flags", 

2069 "input": "hidden", 

2070 } 

2071 

2072 FLAG_DEADLINE = { 

2073 "subfield": True, 

2074 "label": "Deadline", 

2075 "name": "flag_deadline", 

2076 "validate": [ 

2077 {"bigenddate": {"message": "This must be a valid date in the BigEnd format (YYYY-MM-DD)", "ignore_empty": True}}, 

2078 {"stop_validation_on_other_value": { 

2079 "field": "flag_resolved", 

2080 "value": "true" 

2081 }}, 

2082 {"required_if": { 

2083 "field": "flag_note", 

2084 "not_empty": True, 

2085 "message": "The flag must have a deadline", 

2086 "skip_disabled": True 

2087 }} 

2088 ], 

2089 "help": { 

2090 "placeholder": "deadline (YYYY-MM-DD)", 

2091 "render_error_box": True, 

2092 "warning_message": Messages.FORMS_APPLICATION_FLAG__PAST_DEADLINE_WARNING 

2093 }, 

2094 "group": "flags", 

2095 "input": "text", 

2096 } 

2097 

2098 FLAG_NOTE = { 

2099 "subfield": True, 

2100 "name": "flag_note", 

2101 "group": "flags", 

2102 "input": "textarea", 

2103 "validate": [ 

2104 {"required_if_active": { 

2105 "message": lazy_gettext("Flag requires a note")}, 

2106 } 

2107 ] 

2108 } 

2109 

2110 # ~~->$ NoteID:FormField~~ 

2111 FLAG_NOTE_ID = { 

2112 "subfield": True, 

2113 "name": "flag_note_id", 

2114 "group": "flags", 

2115 "input": "hidden" 

2116 } 

2117 

2118 FLAG_ASSIGNEE = { 

2119 "subfield": True, 

2120 "name": "flag_assignee", 

2121 "label": "Assign an admin", 

2122 "help": { 

2123 "placeholder": "Username" 

2124 }, 

2125 "group": "flags", 

2126 "validate": [ 

2127 "reserved_usernames", 

2128 "owner_exists", 

2129 {"stop_validation_on_other_value": { 

2130 "field": "flag_resolved", 

2131 "value": "true" 

2132 }}, 

2133 {"required_if": { 

2134 "field": "flag_note", 

2135 "not_empty": True, 

2136 "message": "The flag must be assigned to someone", 

2137 "skip_disabled": True 

2138 }} 

2139 ], 

2140 "widgets": [ 

2141 {"autocomplete": {"type": "admin", "include": False, "allow_clear_input": False}}, 

2142 # ~~^-> Autocomplete:FormWidget~~ 

2143 ], 

2144 "input": "text", 

2145 } 

2146 

2147 # ~~->$ OptionalValidation:FormField~~ 

2148 OPTIONAL_VALIDATION = { 

2149 "name": "make_all_fields_optional", 

2150 "label": lazy_gettext("Allow save without validation"), 

2151 "input": "checkbox", 

2152 "widget": { 

2153 "optional_validation" 

2154 } 

2155 } 

2156 

2157 LAST_FULL_REVIEW = { 

2158 "optional": True, 

2159 "label": "Last Full Review Date", 

2160 "name": "last_full_review", 

2161 "validate": [ 

2162 {"bigenddate": {"message": "This must be a valid date in the BigEnd format (YYYY-MM-DD)"}}, 

2163 {"date_in_the_past": {"message": "The date must be in the past"}} 

2164 ], 

2165 "help": { 

2166 "placeholder": "last full review (YYYY-MM-DD)", 

2167 "render_error_box": True, 

2168 "short_help": "If you have just completed a full review of this Journal, enter the date here." 

2169 }, 

2170 "input": "text", # although this is a date, the text input is the best one to use because the widget will force that type anyway 

2171 "widgets": [ 

2172 {"date_picker": {"earlier_than_now": True}} # ~~^-> DatePicker:FormWidget~~ 

2173 ] 

2174 } 

2175 

2176 MARK_AS_FULL_REVIEW = { 

2177 "name": "mark_as_full_review", 

2178 "label": "This update request constitutes a full review of the journal", 

2179 "input": "checkbox" 

2180 } 

2181 

2182 

2183########################################################## 

2184# Define our fieldsets 

2185########################################################## 

2186 

2187class FieldSetDefinitions: 

2188 # ~~->$ BasicCompliance:FieldSet~~ 

2189 BASIC_COMPLIANCE = { 

2190 "name": "basic_compliance", 

2191 "label": lazy_gettext("Open access compliance"), 

2192 "fields": [ 

2193 FieldDefinitions.BOAI["name"], 

2194 FieldDefinitions.OA_STATEMENT_URL["name"], 

2195 FieldDefinitions.OA_START["name"] 

2196 ] 

2197 } 

2198 

2199 # ~~->$ AboutJournal:FieldSet~~ 

2200 ABOUT_THE_JOURNAL = { 

2201 "name": "about_the_journal", 

2202 "label": lazy_gettext("About the journal"), 

2203 "fields": [ 

2204 FieldDefinitions.TITLE["name"], 

2205 FieldDefinitions.ALTERNATIVE_TITLE["name"], 

2206 FieldDefinitions.JOURNAL_URL["name"], 

2207 FieldDefinitions.PISSN["name"], 

2208 FieldDefinitions.EISSN["name"], 

2209 FieldDefinitions.LANGUAGE["name"], 

2210 ] 

2211 } 

2212 

2213 ABOUT_THE_JOURNAL_EXTENDED = { 

2214 "name": "about_the_journal_extended", 

2215 "label": "About the journal", 

2216 "fields": ABOUT_THE_JOURNAL["fields"] + [FieldDefinitions.KEYWORDS["name"]] 

2217 } 

2218 

2219 

2220 # ~~->$ Publisher:FieldSet~~ 

2221 PUBLISHER = { 

2222 "name": "publisher", 

2223 "label": lazy_gettext("Publisher"), 

2224 "fields": [ 

2225 FieldDefinitions.PUBLISHER_NAME["name"], 

2226 FieldDefinitions.PUBLISHER_COUNTRY["name"], 

2227 ] 

2228 } 

2229 

2230 # ~~->$ Institution:FieldSet~~ 

2231 SOCIETY_OR_INSTITUTION = { 

2232 "name": "society_or_institution", 

2233 "label": lazy_gettext("Other organisation, if applicable"), 

2234 "fields": [ 

2235 FieldDefinitions.INSTITUTION_NAME["name"], 

2236 FieldDefinitions.INSTITUTION_COUNTRY["name"] 

2237 ] 

2238 } 

2239 

2240 # ~~->$ Licensing:FieldSet~~ 

2241 LICENSING = { 

2242 "name": "licensing", 

2243 "label": lazy_gettext("Licensing"), 

2244 "fields": [ 

2245 FieldDefinitions.LICENSE["name"], 

2246 FieldDefinitions.LICENSE_ATTRIBUTES["name"], 

2247 FieldDefinitions.LICENSE_TERMS_URL["name"] 

2248 ] 

2249 } 

2250 

2251 # ~~->$ EmbeddedLicense:FieldSet~~ 

2252 EMBEDDED_LICENSING = { 

2253 "name": "embedded_licensing", 

2254 "label": lazy_gettext("Embedded licenses"), 

2255 "fields": [ 

2256 FieldDefinitions.LICENSE_DISPLAY["name"], 

2257 FieldDefinitions.LICENSE_DISPLAY_EXAMPLE_URL["name"] 

2258 ] 

2259 } 

2260 

2261 # ~~->$ Copyright:FieldSet~~ 

2262 COPYRIGHT = { 

2263 "name": "copyright", 

2264 "label": lazy_gettext("Copyright"), 

2265 "fields": [ 

2266 FieldDefinitions.COPYRIGHT_AUTHOR_RETAINS["name"], 

2267 FieldDefinitions.COPYRIGHT_URL["name"] 

2268 ] 

2269 } 

2270 

2271 # ~~->$ PeerReview:FieldSet~~ 

2272 PEER_REVIEW = { 

2273 "name": "peer_review", 

2274 "label": lazy_gettext("Peer review"), 

2275 "fields": [ 

2276 FieldDefinitions.REVIEW_PROCESS["name"], 

2277 FieldDefinitions.REVIEW_PROCESS_OTHER["name"], 

2278 FieldDefinitions.REVIEW_URL["name"] 

2279 ] 

2280 } 

2281 

2282 # ~~->$ Plagiarism:FieldSet~~ 

2283 PLAGIARISM = { 

2284 "name": "plagiarism", 

2285 "label": lazy_gettext("Plagiarism"), 

2286 "fields": [ 

2287 FieldDefinitions.PLAGIARISM_DETECTION["name"], 

2288 FieldDefinitions.PLAGIARISM_URL["name"] 

2289 ] 

2290 } 

2291 

2292 # ~~->$ Editorial:FieldSet~~ 

2293 EDITORIAL = { 

2294 "name": "editorial", 

2295 "label": lazy_gettext("Editorial"), 

2296 "fields": [ 

2297 FieldDefinitions.AIMS_SCOPE_URL["name"], 

2298 FieldDefinitions.EDITORIAL_BOARD_URL["name"], 

2299 FieldDefinitions.AUTHOR_INSTRUCTIONS_URL["name"], 

2300 FieldDefinitions.PUBLICATION_TIME_WEEKS["name"], 

2301 ] 

2302 } 

2303 

2304 SUBJECT_AND_KEYWORDS = { 

2305 "name": "subject_and_keywords", 

2306 "label": lazy_gettext("Keywords and Subject"), 

2307 "fields": [FieldDefinitions.KEYWORDS["name"], FieldDefinitions.SUBJECT["name"]] 

2308 } 

2309 

2310 # ~~->$ APC:FieldSet~~ 

2311 APC = { 

2312 "name": "apc", 

2313 "label": lazy_gettext("Publication fees"), 

2314 "fields": [ 

2315 FieldDefinitions.APC["name"], 

2316 FieldDefinitions.APC_CHARGES["name"], 

2317 FieldDefinitions.APC_CURRENCY["name"], 

2318 FieldDefinitions.APC_MAX["name"], 

2319 FieldDefinitions.APC_URL["name"] 

2320 ] 

2321 } 

2322 

2323 # ~~->$ Waivers:FieldSet~~ 

2324 APC_WAIVERS = { 

2325 "name": "apc_waivers", 

2326 "label": lazy_gettext("Publication fee waivers"), 

2327 "fields": [ 

2328 FieldDefinitions.HAS_WAIVER["name"], 

2329 FieldDefinitions.WAIVER_URL["name"] 

2330 ] 

2331 } 

2332 

2333 # ~~->$ OtherFees:FieldSet~~ 

2334 OTHER_FEES = { 

2335 "name": "other_fees", 

2336 "label": lazy_gettext("Other fees"), 

2337 "fields": [ 

2338 FieldDefinitions.HAS_OTHER_CHARGES["name"], 

2339 FieldDefinitions.OTHER_CHARGES_URL["name"] 

2340 ] 

2341 } 

2342 

2343 # ~~->$ ArchivingPolicy:FieldSet~~ 

2344 ARCHIVING_POLICY = { 

2345 "name": "archiving_policy", 

2346 "label": lazy_gettext("Archiving policy"), 

2347 "fields": [ 

2348 FieldDefinitions.PRESERVATION_SERVICE["name"], 

2349 FieldDefinitions.PRESERVATION_SERVICE_LIBRARY["name"], 

2350 FieldDefinitions.PRESERVATION_SERVICE_OTHER["name"], 

2351 FieldDefinitions.PRESERVATION_SERVICE_URL["name"] 

2352 ] 

2353 } 

2354 

2355 # ~~->$ RepositoryPolicy:FieldSet~~ 

2356 REPOSITORY_POLICY = { 

2357 "name": "deposit_policy", 

2358 "label": lazy_gettext("Repository policy"), 

2359 "fields": [ 

2360 FieldDefinitions.DEPOSIT_POLICY["name"], 

2361 FieldDefinitions.DEPOSIT_POLICY_OTHER["name"], 

2362 FieldDefinitions.DEPOSIT_POLICY_URL["name"] 

2363 ] 

2364 } 

2365 

2366 # ~~->$ UniqueIdentifiers:FieldSet~~ 

2367 UNIQUE_IDENTIFIERS = { 

2368 "name": "unique_identifiers", 

2369 "label": lazy_gettext("Unique identifiers & structured data"), 

2370 "fields": [ 

2371 FieldDefinitions.PERSISTENT_IDENTIFIERS["name"], 

2372 FieldDefinitions.PERSISTENT_IDENTIFIERS_OTHER["name"] 

2373 ] 

2374 } 

2375 

2376 

2377 LABELS = { 

2378 "name": "labels", 

2379 "label": lazy_gettext("Specify labels for this journal"), 

2380 "fields": [ 

2381 FieldDefinitions.S2O["name"], 

2382 FieldDefinitions.MIRROR["name"], 

2383 FieldDefinitions.OJC["name"] 

2384 ] 

2385 } 

2386 

2387 # ~~->$ QuickReject:FieldSet~~ 

2388 # ~~^-> QuickReject:Feature~~ 

2389 QUICK_REJECT = { 

2390 "name": "quick_reject", 

2391 "label": lazy_gettext("Quick reject"), 

2392 "fields": [ 

2393 FieldDefinitions.QUICK_REJECT["name"], 

2394 FieldDefinitions.QUICK_REJECT_DETAILS["name"] 

2395 ] 

2396 } 

2397 

2398 # ~~->$ Reassign:FieldSet~~ 

2399 REASSIGN = { 

2400 "name": "reassign", 

2401 "label": lazy_gettext("Re-assign publisher account"), 

2402 "fields": [ 

2403 FieldDefinitions.OWNER["name"] 

2404 ] 

2405 } 

2406 

2407 LAST_FULL_REVIEW = { 

2408 "name": "last_full_review", 

2409 "label": "Last Full Review", 

2410 "fields": [ 

2411 FieldDefinitions.LAST_FULL_REVIEW["name"] 

2412 ] 

2413 } 

2414 

2415 MARK_AS_FULL_REVIEW = { 

2416 "name": "mark_as_full_review", 

2417 "label": "Mark as full review", 

2418 "fields": [ 

2419 FieldDefinitions.MARK_AS_FULL_REVIEW["name"] 

2420 ] 

2421 } 

2422 

2423 # ~~->$ Status:FieldSet~~ 

2424 STATUS = { 

2425 "name": "status", 

2426 "label": lazy_gettext("Status"), 

2427 "fields": [ 

2428 FieldDefinitions.APPLICATION_STATUS["name"] 

2429 ] 

2430 } 

2431 

2432 # ~~->$ Reviewers:FieldSet~~ 

2433 REVIEWERS = { 

2434 "name": "reviewers", 

2435 "label": lazy_gettext("Assign for review"), 

2436 "fields": [ 

2437 FieldDefinitions.EDITOR_GROUP["name"], 

2438 FieldDefinitions.EDITOR["name"] 

2439 ] 

2440 } 

2441 

2442 # ~~->$ Continuations:FieldSet~~ 

2443 # ~~^-> Continuations:Feature~~ 

2444 CONTINUATIONS = { 

2445 "name": "continuations", 

2446 "label": lazy_gettext("Continuations"), 

2447 "fields": [ 

2448 FieldDefinitions.CONTINUES["name"], 

2449 FieldDefinitions.CONTINUED_BY["name"], 

2450 FieldDefinitions.DISCONTINUED_DATE["name"] 

2451 ] 

2452 } 

2453 

2454 # ~~->$ Notes:FieldSet~~ 

2455 NOTES = { 

2456 "name": "notes", 

2457 "label": lazy_gettext("Notes"), 

2458 "fields": [ 

2459 FieldDefinitions.NOTES["name"], 

2460 FieldDefinitions.NOTE["name"], 

2461 FieldDefinitions.NOTE_AUTHOR["name"], 

2462 FieldDefinitions.NOTE_DATE["name"], 

2463 FieldDefinitions.NOTE_ID["name"], 

2464 FieldDefinitions.NOTE_AUTHOR_ID["name"] 

2465 ] 

2466 } 

2467 

2468 FLAGS = { 

2469 "name": "flags", 

2470 "label": "Flag", 

2471 "fields": [ 

2472 FieldDefinitions.FLAGS["name"], 

2473 FieldDefinitions.FLAG_SETTER["name"], 

2474 FieldDefinitions.FLAG_CREATED_DATE["name"], 

2475 FieldDefinitions.FLAG_DEADLINE["name"], 

2476 FieldDefinitions.FLAG_NOTE["name"], 

2477 FieldDefinitions.FLAG_NOTE_ID["name"], 

2478 FieldDefinitions.FLAG_ASSIGNEE["name"], 

2479 FieldDefinitions.FLAG_RESOLVED["name"], 

2480 ] 

2481 } 

2482 

2483 # ~~->$ OptionalValidation:FieldSet~~ 

2484 OPTIONAL_VALIDATION = { 

2485 "name": "optional_validation", 

2486 "label": lazy_gettext("Allow save without validation"), 

2487 "fields": [ 

2488 FieldDefinitions.OPTIONAL_VALIDATION["name"] 

2489 ] 

2490 } 

2491 

2492 # ~~->$ BulkEdit:FieldSet~~ 

2493 # ~~^-> BulkEdit:Feature~~ 

2494 BULK_EDIT = { 

2495 "name": "bulk_edit", 

2496 "label": lazy_gettext("Bulk edit"), 

2497 "fields": [ 

2498 FieldDefinitions.PUBLISHER_NAME["name"], 

2499 FieldDefinitions.PUBLISHER_COUNTRY["name"], 

2500 FieldDefinitions.OWNER["name"] 

2501 ] 

2502 } 

2503 

2504 

2505########################################################### 

2506# Define our Contexts 

2507########################################################### 

2508 

2509class ApplicationContextDefinitions: 

2510 # ~~->$ NewApplication:FormContext~~ 

2511 # ~~^-> ApplicationForm:Crosswalk~~ 

2512 # ~~^-> NewApplication:FormProcessor~~ 

2513 

2514 PUBLIC = { 

2515 "name": "public", 

2516 "fieldsets": [ 

2517 FieldSetDefinitions.BASIC_COMPLIANCE["name"], 

2518 FieldSetDefinitions.PUBLISHER["name"], 

2519 FieldSetDefinitions.SOCIETY_OR_INSTITUTION["name"], 

2520 FieldSetDefinitions.LICENSING["name"], 

2521 FieldSetDefinitions.EMBEDDED_LICENSING["name"], 

2522 FieldSetDefinitions.COPYRIGHT["name"], 

2523 FieldSetDefinitions.PEER_REVIEW["name"], 

2524 FieldSetDefinitions.PLAGIARISM["name"], 

2525 FieldSetDefinitions.APC["name"], 

2526 FieldSetDefinitions.APC_WAIVERS["name"], 

2527 FieldSetDefinitions.OTHER_FEES["name"], 

2528 FieldSetDefinitions.EDITORIAL["name"], 

2529 FieldSetDefinitions.ARCHIVING_POLICY["name"], 

2530 FieldSetDefinitions.REPOSITORY_POLICY["name"], 

2531 FieldSetDefinitions.UNIQUE_IDENTIFIERS["name"] 

2532 ], 

2533 "templates": { 

2534 "form": templates.PUBLIC_APPLICATION_FORM, 

2535 "default_field": templates.AF_FIELD, 

2536 "default_group": templates.AF_GROUP 

2537 }, 

2538 "crosswalks": { 

2539 "obj2form": ApplicationFormXWalk.obj2form, 

2540 "form2obj": ApplicationFormXWalk.form2obj 

2541 }, 

2542 "processor": application_processors.NewApplication, 

2543 } 

2544 

2545 # ~~->$ UpdateRequest:FormContext~~ 

2546 # ~~^-> NewApplication:FormContext~~ 

2547 # ~~^-> UpdateRequest:FormProcessor~~ 

2548 UPDATE = deepcopy(PUBLIC) 

2549 UPDATE["name"] = "update_request" 

2550 UPDATE["processor"] = application_processors.PublisherUpdateRequest 

2551 UPDATE["templates"]["form"] = templates.PUBLISHER_UPDATE_REQUEST_FORM 

2552 

2553 # ~~->$ ReadOnlyApplication:FormContext~~ 

2554 # ~~^-> NewApplication:FormContext~~ 

2555 READ_ONLY = deepcopy(PUBLIC) 

2556 READ_ONLY["name"] = "application_read_only" 

2557 READ_ONLY["processor"] = application_processors.NewApplication # FIXME: enter the real processor 

2558 READ_ONLY["templates"]["form"] = templates.PUBLISHER_READ_ONLY_APPLICATION 

2559 

2560 # ~~->$ AssociateEditorApplication:FormContext~~ 

2561 # ~~^-> NewApplication:FormContext~~ 

2562 # ~~^-> AssociateEditorApplication:FormProcessor~~ 

2563 ASSOCIATE = deepcopy(PUBLIC) 

2564 ASSOCIATE["name"] = "associate_editor" 

2565 ASSOCIATE["fieldsets"] += [ 

2566 FieldSetDefinitions.STATUS["name"], 

2567 FieldSetDefinitions.NOTES["name"] 

2568 ] 

2569 ASSOCIATE["processor"] = application_processors.AssociateApplication 

2570 ASSOCIATE["templates"]["form"] = templates.ASSED_APPLICATION_FORM 

2571 

2572 # ~~->$ EditorApplication:FormContext~~ 

2573 # ~~^-> NewApplication:FormContext~~ 

2574 # ~~^-> EditorApplication:FormProcessor~~ 

2575 EDITOR = deepcopy(PUBLIC) 

2576 EDITOR["name"] = "editor" 

2577 EDITOR["fieldsets"] += [ 

2578 FieldSetDefinitions.STATUS["name"], 

2579 FieldSetDefinitions.REVIEWERS["name"], 

2580 FieldSetDefinitions.NOTES["name"] 

2581 ] 

2582 EDITOR["processor"] = application_processors.EditorApplication 

2583 EDITOR["templates"]["form"] = templates.EDITOR_APPLICATION_FORM 

2584 

2585 # ~~->$ ManEdApplication:FormContext~~ 

2586 # ~~^-> NewApplication:FormContext~~ 

2587 # ~~^-> ManEdApplication:FormProcessor~~ 

2588 MANED = deepcopy(PUBLIC) 

2589 MANED["name"] = "admin" 

2590 MANED["fieldsets"] += [ 

2591 FieldSetDefinitions.LABELS["name"], 

2592 FieldSetDefinitions.QUICK_REJECT["name"], 

2593 FieldSetDefinitions.REASSIGN["name"], 

2594 FieldSetDefinitions.STATUS["name"], 

2595 FieldSetDefinitions.REVIEWERS["name"], 

2596 FieldSetDefinitions.CONTINUATIONS["name"], 

2597 FieldSetDefinitions.NOTES["name"], 

2598 FieldSetDefinitions.MARK_AS_FULL_REVIEW["name"], 

2599 ] 

2600 MANED["processor"] = application_processors.AdminApplication 

2601 MANED["templates"]["form"] = templates.MANED_APPLICATION_FORM 

2602 

2603 # add about the journal and editorial fields that differ between the contexts 

2604 public_context = [PUBLIC, READ_ONLY, UPDATE] 

2605 for pc in public_context: 

2606 pc["fieldsets"] += [FieldSetDefinitions.ABOUT_THE_JOURNAL_EXTENDED["name"]] 

2607 

2608 editorial_context = [ASSOCIATE, EDITOR, MANED] 

2609 for ec in editorial_context: 

2610 ec["fieldsets"] += [FieldSetDefinitions.ABOUT_THE_JOURNAL["name"], FieldSetDefinitions.SUBJECT_AND_KEYWORDS["name"]] 

2611 

2612class JournalContextDefinitions: 

2613 # ~~->$ ReadOnlyJournal:FormContext~~ 

2614 # ~~^-> JournalForm:Crosswalk~~ 

2615 # ~~^-> ReadOnlyJournal:FormProcessor~~ 

2616 ADMIN_READ_ONLY = { 

2617 "name": "admin_readonly", 

2618 "fieldsets": [ 

2619 FieldSetDefinitions.BASIC_COMPLIANCE["name"], 

2620 FieldSetDefinitions.ABOUT_THE_JOURNAL["name"], 

2621 FieldSetDefinitions.PUBLISHER["name"], 

2622 FieldSetDefinitions.SOCIETY_OR_INSTITUTION["name"], 

2623 FieldSetDefinitions.LICENSING["name"], 

2624 FieldSetDefinitions.EMBEDDED_LICENSING["name"], 

2625 FieldSetDefinitions.COPYRIGHT["name"], 

2626 FieldSetDefinitions.PEER_REVIEW["name"], 

2627 FieldSetDefinitions.PLAGIARISM["name"], 

2628 FieldSetDefinitions.EDITORIAL["name"], 

2629 FieldSetDefinitions.SUBJECT_AND_KEYWORDS["name"], 

2630 FieldSetDefinitions.APC["name"], 

2631 FieldSetDefinitions.APC_WAIVERS["name"], 

2632 FieldSetDefinitions.OTHER_FEES["name"], 

2633 FieldSetDefinitions.ARCHIVING_POLICY["name"], 

2634 FieldSetDefinitions.REPOSITORY_POLICY["name"], 

2635 FieldSetDefinitions.UNIQUE_IDENTIFIERS["name"], 

2636 

2637 ], 

2638 "templates": { 

2639 "form": templates.MANED_READ_ONLY_JOURNAL, 

2640 "default_field": templates.AF_FIELD, 

2641 "default_group": templates.AF_GROUP 

2642 }, 

2643 "crosswalks": { 

2644 "obj2form": JournalFormXWalk.obj2form, 

2645 "form2obj": JournalFormXWalk.form2obj 

2646 }, 

2647 "processor": application_processors.ReadOnlyJournal 

2648 } 

2649 

2650 # identical context for editors, mostly to support the different view contexts 

2651 EDITOR_READ_ONLY = deepcopy(ADMIN_READ_ONLY) 

2652 EDITOR_READ_ONLY["name"] = "editor_readonly" 

2653 EDITOR_READ_ONLY["templates"]["form"] = templates.EDITOR_READ_ONLY_JOURNAL 

2654 

2655 # ~~->$ AssEditorJournal:FormContext~~ 

2656 # ~~^-> ReadOnlyJournal:FormContext~~ 

2657 # ~~^-> AssEdJournal:FormProcessor~~ 

2658 ASSOCIATE = deepcopy(ADMIN_READ_ONLY) 

2659 ASSOCIATE["fieldsets"] += [ 

2660 FieldSetDefinitions.NOTES["name"] 

2661 ] 

2662 ASSOCIATE["name"] = "associate_editor" 

2663 ASSOCIATE["processor"] = application_processors.AssEdJournalReview 

2664 ASSOCIATE["templates"]["form"] = templates.ASSED_JOURNAL_FORM 

2665 

2666 # ~~->$ EditorJournal:FormContext~~ 

2667 # ~~^-> AssEdJournal:FormContext~~ 

2668 # ~~^-> EditorJournal:FormProcessor~~ 

2669 EDITOR = deepcopy(ASSOCIATE) 

2670 EDITOR["name"] = "editor" 

2671 EDITOR["fieldsets"] += [ 

2672 FieldSetDefinitions.REVIEWERS["name"] 

2673 ] 

2674 EDITOR["processor"] = application_processors.EditorJournalReview 

2675 EDITOR["templates"]["form"] = templates.EDITOR_JOURNAL_FORM 

2676 

2677 # ~~->$ ManEdJournal:FormContext~~ 

2678 # ~~^-> EditorJournal:FormContext~~ 

2679 # ~~^-> ManEdJournal:FormProcessor~~ 

2680 MANED = deepcopy(EDITOR) 

2681 MANED["name"] = "admin" 

2682 MANED["fieldsets"] += [ 

2683 FieldSetDefinitions.REASSIGN["name"], 

2684 FieldSetDefinitions.OPTIONAL_VALIDATION["name"], 

2685 FieldSetDefinitions.LABELS["name"], 

2686 FieldSetDefinitions.CONTINUATIONS["name"], 

2687 FieldSetDefinitions.FLAGS["name"], 

2688 FieldSetDefinitions.LAST_FULL_REVIEW["name"] 

2689 ] 

2690 MANED["processor"] = application_processors.ManEdJournalReview 

2691 MANED["templates"]["form"] = templates.MANED_JOURNAL_FORM 

2692 

2693 # ~~->$ BulkEditJournal:FormContext~~ 

2694 # ~~^-> JournalForm:Crosswalk~~ 

2695 # ~~^-> ManEdJournal:FormProcessor~~ 

2696 BULK_EDIT = { 

2697 "name": "bulk_edit", 

2698 "fieldsets": [ 

2699 FieldSetDefinitions.BULK_EDIT["name"] 

2700 ], 

2701 "templates": { 

2702 "form": templates.MANED_JOURNAL_BULK_EDIT, 

2703 "default_field": templates.AF_FIELD, 

2704 "default_group": templates.AF_GROUP 

2705 }, 

2706 "crosswalks": { 

2707 "obj2form": JournalFormXWalk.obj2form, 

2708 "form2obj": JournalFormXWalk.form2obj 

2709 }, 

2710 "processor": application_processors.ManEdBulkEdit 

2711 } 

2712 

2713 

2714####################################################### 

2715# Gather all of our form information in one place 

2716####################################################### 

2717 

2718APPLICATION_FORMS = { 

2719 "contexts": { 

2720 ApplicationContextDefinitions.PUBLIC["name"]: ApplicationContextDefinitions.PUBLIC, 

2721 ApplicationContextDefinitions.UPDATE["name"]: ApplicationContextDefinitions.UPDATE, 

2722 ApplicationContextDefinitions.READ_ONLY["name"]: ApplicationContextDefinitions.READ_ONLY, 

2723 ApplicationContextDefinitions.ASSOCIATE["name"]: ApplicationContextDefinitions.ASSOCIATE, 

2724 ApplicationContextDefinitions.EDITOR["name"]: ApplicationContextDefinitions.EDITOR, 

2725 ApplicationContextDefinitions.MANED["name"]: ApplicationContextDefinitions.MANED 

2726 }, 

2727 "fieldsets": {v['name']: v for k, v in FieldSetDefinitions.__dict__.items() if not k.startswith('_')}, 

2728 "fields": {v['name']: v for k, v in FieldDefinitions.__dict__.items() if not k.startswith('_')} 

2729} 

2730 

2731JOURNAL_FORMS = { 

2732 "contexts": { 

2733 JournalContextDefinitions.ADMIN_READ_ONLY["name"]: JournalContextDefinitions.ADMIN_READ_ONLY, 

2734 JournalContextDefinitions.EDITOR_READ_ONLY["name"]: JournalContextDefinitions.EDITOR_READ_ONLY, 

2735 JournalContextDefinitions.BULK_EDIT["name"]: JournalContextDefinitions.BULK_EDIT, 

2736 JournalContextDefinitions.ASSOCIATE["name"]: JournalContextDefinitions.ASSOCIATE, 

2737 JournalContextDefinitions.EDITOR["name"]: JournalContextDefinitions.EDITOR, 

2738 JournalContextDefinitions.MANED["name"]: JournalContextDefinitions.MANED 

2739 }, 

2740 "fieldsets": APPLICATION_FORMS["fieldsets"], 

2741 "fields": APPLICATION_FORMS["fields"] 

2742} 

2743 

2744 

2745####################################################### 

2746# Options lists 

2747####################################################### 

2748 

2749def iso_country_list(field, formualic_context_name): 

2750 # ~~-> Countries:Data~~ 

2751 cl = [{"display": " ", "value": ""}] 

2752 for v, d in country_options: 

2753 cl.append({"display": d, "value": v}) 

2754 return cl 

2755 

2756 

2757def iso_language_list(field, formulaic_context_name): 

2758 # ~~-> Languages:Data~~ 

2759 cl = [{"display": " ", "value": ""}] 

2760 for v, d in language_options: 

2761 cl.append({"display": d, "value": v}) 

2762 return cl 

2763 

2764 

2765def iso_currency_list(field, formulaic_context_name): 

2766 # ~~-> Currencies:Data~~ 

2767 cl = [{"display": " ", "value": ""}] 

2768 quick_pick = [] 

2769 for v, d in currency_options: 

2770 if v in ["GBP", "USD", "EUR"]: 

2771 quick_pick.append({"display": d, "value": v}) 

2772 cl.append({"display": d, "value": v}) 

2773 if len(quick_pick) > 0: 

2774 cl = quick_pick + cl 

2775 return cl 

2776 

2777 

2778def quick_reject(field, formulaic_context_name): 

2779 # ~~-> QuickReject:Feature~~ 

2780 return [{"display": lazy_gettext("Other"), "value": ""}] + [{'display': v, 'value': v} for v in 

2781 app.config.get('QUICK_REJECT_REASONS', [])] 

2782 

2783 

2784def application_statuses(field, formulaic_context): 

2785 # ~~->$ ApplicationStatus:Workflow~~ 

2786 # ~~-> ApplicationStatuses:Config~~ 

2787 _application_status_base = [ # This is all the Associate Editor sees 

2788 ('', ' '), 

2789 (constants.APPLICATION_STATUS_PENDING, Messages.FORMS__APPLICATION_STATUS__PENDING), 

2790 (constants.APPLICATION_STATUS_IN_PROGRESS, Messages.FORMS__APPLICATION_STATUS__IN_PROGRESS), 

2791 (constants.APPLICATION_STATUS_COMPLETED, Messages.FORMS__APPLICATION_STATUS__COMPLETED) 

2792 ] 

2793 

2794 # Note that an admin is given the Post Submission Automation status, as technically they 

2795 # may edit an item that's in this status, but it is functionally useless to them 

2796 # It would be nice to be able to somehow disable it being changed, perhaps we can do that 

2797 # via a widget 

2798 _application_status_admin = _application_status_base + [ 

2799 (constants.APPLICATION_STATUS_POST_SUBMISSION_REVIEW, 

2800 Messages.FORMS__APPLICATION_STATUS__POST_SUBMISSION_REVIEW), 

2801 (constants.APPLICATION_STATUS_UPDATE_REQUEST, Messages.FORMS__APPLICATION_STATUS__UPDATE_REQUEST), 

2802 (constants.APPLICATION_STATUS_REVISIONS_REQUIRED, Messages.FORMS__APPLICATION_STATUS__REVISIONS_REQUIRED), 

2803 (constants.APPLICATION_STATUS_ON_HOLD, Messages.FORMS__APPLICATION_STATUS__ON_HOLD), 

2804 (constants.APPLICATION_STATUS_READY, Messages.FORMS__APPLICATION_STATUS__READY), 

2805 (constants.APPLICATION_STATUS_REJECTED, Messages.FORMS__APPLICATION_STATUS__REJECTED), 

2806 (constants.APPLICATION_STATUS_ACCEPTED, Messages.FORMS__APPLICATION_STATUS__ACCEPTED) 

2807 ] 

2808 

2809 _application_status_editor = _application_status_base + [ 

2810 (constants.APPLICATION_STATUS_READY, Messages.FORMS__APPLICATION_STATUS__READY), 

2811 ] 

2812 

2813 formulaic_context_name = None 

2814 if formulaic_context is not None: 

2815 formulaic_context_name = formulaic_context.name 

2816 

2817 status_list = [] 

2818 if formulaic_context_name is None or formulaic_context_name == "admin": 

2819 status_list = _application_status_admin 

2820 elif formulaic_context_name == "editor": 

2821 status_list = _application_status_editor 

2822 elif formulaic_context_name == "accepted": 

2823 status_list = [(constants.APPLICATION_STATUS_ACCEPTED, 

2824 Messages.FORMS__APPLICATION_STATUS__ACCEPTED)] # just the one status - Accepted 

2825 else: 

2826 status_list = _application_status_base 

2827 

2828 return [{'display': d, 'value': v} for (v, d) in status_list] 

2829 

2830 

2831def editor_choices(field, formulaic_context): 

2832 """ 

2833 Set the editor field choices from a given editor group name 

2834 ~~->EditorGroup:Model~~ 

2835 """ 

2836 egf = formulaic_context.get("editor_group") 

2837 wtf = egf.wtfield 

2838 if wtf is None: 

2839 return [{"display": "", "value": ""}] 

2840 

2841 editor_group_name = wtf.data 

2842 if editor_group_name is None: 

2843 return [{"display": "", "value": ""}] 

2844 else: 

2845 eg = EditorGroup.pull_by_key("name", editor_group_name) 

2846 if eg is not None: 

2847 editors = [eg.editor] 

2848 editors += eg.associates 

2849 editors = list(set(editors)) 

2850 return [{"value": "", "display": lazy_gettext("No editor assigned")}] + [{"value": editor, "display": editor} for editor 

2851 in editors] 

2852 else: 

2853 return [{"display": "", "value": ""}] 

2854 

2855 

2856####################################################### 

2857## Conditional disableds 

2858####################################################### 

2859 

2860def application_status_disabled(field, formulaic_context): 

2861 choices = application_statuses(field, formulaic_context) 

2862 field_value = field.wtfield.data 

2863 return field_value not in [c.get("value") for c in choices] 

2864 

2865 

2866def disable_edit_note_except_editing_user(field: FormulaicField, 

2867 formulaic_context: FormulaicContext): 

2868 """ 

2869 Only allow the current user to edit this field if author is current user 

2870 

2871 :param field: 

2872 :param formulaic_context: 

2873 :return: 

2874 False is editable, True is disabled 

2875 """ 

2876 

2877 # ~~->Notes:Feature~~ 

2878 editing_user = formulaic_context.extra_param.get('editing_user') 

2879 cur_user_id = editing_user and editing_user.id 

2880 form_field: FormField = field.find_related_form_field('notes', formulaic_context) 

2881 if form_field is None: 

2882 return True 

2883 return cur_user_id != form_field.data.get('note_author_id') 

2884 

2885 

2886def disable_edit_flag_except_author_admin_assignee(field: FormulaicField, 

2887 formulaic_context: FormulaicContext): 

2888 # This is currently not used but will be needed again when the flags feature will be made available for non-admin users 

2889 

2890 """ 

2891 Only allow the current user to edit this field if current user is an author, assignee or admin 

2892 

2893 :param field: 

2894 :param formulaic_context: 

2895 :return: 

2896 False is editable, True is disabled 

2897 """ 

2898 

2899 # ~~->Notes:Feature~~ 

2900 editing_user = formulaic_context.extra_param.get('editing_user') 

2901 cur_user_id = editing_user and editing_user.id 

2902 cur_user_is_admin = editing_user and editing_user.is_super 

2903 form_field: FormField = field.find_related_form_field('notes', formulaic_context) 

2904 if form_field is None: 

2905 return True 

2906 

2907 return (cur_user_id != form_field.data.get('flag_assignee') and 

2908 cur_user_id != form_field.data.get('flag_setter') and 

2909 not cur_user_is_admin) 

2910 

2911 

2912####################################################### 

2913## Merge disabled 

2914####################################################### 

2915 

2916def merge_disabled_notes(notes_group, original_form): 

2917 # ~~->Notes:Feature~~ 

2918 merged = [] 

2919 wtf = notes_group.wtfield 

2920 for entry in wtf.entries: 

2921 if entry.data.get("note") != "" or entry.data.get("note_id") != "": 

2922 merged.append(entry.data) 

2923 for entry in original_form.notes.entries: 

2924 d = entry.data 

2925 for m in merged: 

2926 if m.get("note_id") != "" and m.get("note_id") == entry.data.get("note_id"): 

2927 # keep = False 

2928 if m.get("note") == "": 

2929 m["note"] = entry.data.get("note") 

2930 m["note_date"] = entry.data.get("note_date") 

2931 break 

2932 

2933 while True: 

2934 try: 

2935 wtf.pop_entry() 

2936 except IndexError: 

2937 break 

2938 

2939 for m in merged: 

2940 wtf.append_entry(m) 

2941 

2942 

2943####################################################### 

2944# Validation features 

2945####################################################### 

2946 

2947class ReservedUsernamesBuilder: 

2948 """ 

2949 ~~->$ ReservedUsernames:FormValidator~~ 

2950 """ 

2951 

2952 @staticmethod 

2953 def render(settings, html_attrs): 

2954 return 

2955 

2956 @staticmethod 

2957 def wtforms(field, settings): 

2958 return ReservedUsernames() 

2959 

2960 

2961class OwnerExistsBuilder: 

2962 """ 

2963 ~~->$ OwnerExists:FormValidator~~ 

2964 """ 

2965 

2966 @staticmethod 

2967 def render(settings, html_attrs): 

2968 return 

2969 

2970 @staticmethod 

2971 def wtforms(field, settings): 

2972 return OwnerExists() 

2973 

2974 

2975class RequiredBuilder: 

2976 """ 

2977 ~~->$ Required:FormValidator~~ 

2978 """ 

2979 

2980 @staticmethod 

2981 def render(settings, html_attrs): 

2982 html_attrs["required"] = "" 

2983 if "message" in settings: 

2984 html_attrs["data-parsley-required-message"] = "<p><small>" + settings["message"] + "</small></p>" 

2985 else: 

2986 html_attrs["data-parsley-required-message"] = "<p><small>" + lazy_gettext("This answer is required") + "</p></small>" 

2987 if settings.get("skip_disabled"): 

2988 html_attrs["data-parsley-validate-if-disabled"] = "false" 

2989 html_attrs["data-parsley-validate-if-empty"] = "true" 

2990 

2991 @staticmethod 

2992 def wtforms(field, settings): 

2993 return CustomRequired(message=settings.get("message")) 

2994 

2995class RequiredIfActiveBuilder: 

2996 """ 

2997 ~~->$ RequiredIfActive:FormValidator~~ 

2998 """ 

2999 

3000 @staticmethod 

3001 def render(settings, html_attrs): 

3002 html_attrs["data-parsley-required-if-active"] = "" 

3003 if "message" in settings: 

3004 html_attrs["data-parsley-required-if-active-message"] = "<p><small>" + settings["message"] + "</small></p>" 

3005 else: 

3006 html_attrs["data-parsley-required-if-active-message"] = "<p><small>" + lazy_gettext( 

3007 "This answer is required") + "</p></small>" 

3008 html_attrs["data-parsley-validate-if-empty"] = "true" 

3009 

3010 @staticmethod 

3011 def wtforms(field, settings): 

3012 return RequiredIfActive(message=settings.get("message")) 

3013 

3014class IsURLBuilder: 

3015 # ~~->$ IsURL:FormValidator~~ 

3016 

3017 @staticmethod 

3018 def _get_msg(): 

3019 text = lazy_gettext("Please enter a valid URL. It should start with http or https") 

3020 return f"<p><small>{text}</small></p>" 

3021 

3022 @staticmethod 

3023 def render(settings, html_attrs): 

3024 html_attrs["type"] = "url" 

3025 html_attrs["pattern"] = regex.HTTP_URL 

3026 html_attrs["data-parsley-pattern"] = regex.HTTP_URL 

3027 html_attrs["data-parsley-pattern-message"] = IsURLBuilder._get_msg() 

3028 

3029 @staticmethod 

3030 def wtforms(field, settings): 

3031 return HTTPURL(message=settings.get('message', IsURLBuilder._get_msg())) 

3032 

3033 

3034class IntRangeBuilder: 

3035 """ 

3036 ~~->$ IntRange:FormValidator~~ 

3037 ~~^-> NumberRange:FormValidator~~ 

3038 """ 

3039 

3040 @staticmethod 

3041 def render(settings, html_attrs): 

3042 html_attrs["data-parsley-type"] = "digits" 

3043 default_msg = "" 

3044 if "gte" in settings and "lte" in settings: 

3045 html_attrs["data-parsley-range"] = "[" + str(settings.get("gte")) + ", " + str(settings.get("lte")) + "]" 

3046 default_msg = lazy_gettext("This value should be between %(min)s and %(max)s", 

3047 min=str(settings.get("gte")), max=str(settings.get("lte"))) 

3048 else: 

3049 if "gte" in settings: 

3050 html_attrs["data-parsley-min"] = settings.get("gte") 

3051 default_msg = lazy_gettext("This value should be bigger than %(gte)s", 

3052 gte=str(settings.get("gte"))) 

3053 if "lte" in settings: 

3054 html_attrs["data-parsley-max"] = settings.get("lte") 

3055 default_msg = lazy_gettext("This value should be smaller than %(lte)s", 

3056 lte=str(settings.get("lte"))) 

3057 html_attrs["data-parsley-range-message"] = "<p><small>" + settings.get("message", default_msg) + "</p></small>" 

3058 

3059 @staticmethod 

3060 def wtforms(field, settings): 

3061 min = settings.get("gte") 

3062 max = settings.get("lte") 

3063 kwargs = {} 

3064 if min is not None: 

3065 kwargs["min"] = min 

3066 if max is not None: 

3067 kwargs["max"] = max 

3068 return validators.NumberRange(**kwargs) 

3069 

3070 

3071class MaxTagsBuilder: 

3072 """ 

3073 ~~->$ MaxLen:FormValidator~~ 

3074 """ 

3075 

3076 @staticmethod 

3077 def wtforms(field, settings): 

3078 max = settings.get("max") 

3079 message = settings.get("message") if "message" in settings else 'You can only enter up to {x} keywords.'.format( 

3080 x=max) 

3081 return MaxLen(max, message=message) 

3082 

3083 

3084class StopWordsBuilder: 

3085 """ 

3086 ~~->$ StopWords:FormValidator~~ 

3087 """ 

3088 

3089 @staticmethod 

3090 def wtforms(field, settings): 

3091 stopwords = settings.get("disallowed", []) 

3092 return StopWords(stopwords) 

3093 

3094 

3095class ISSNInPublicDOAJBuilder: 

3096 """ 

3097 ~~->$ ISSNInPublicDOAJ:FormValidator~~ 

3098 """ 

3099 

3100 @staticmethod 

3101 def render(settings, html_attrs): 

3102 # FIXME: not yet implemented in the front end, so setting here is speculative 

3103 html_attrs["data-parsley-issn-in-public-doaj"] = "" 

3104 

3105 @staticmethod 

3106 def wtforms(field, settings): 

3107 return ISSNInPublicDOAJ(message=settings.get("message")) 

3108 

3109 

3110class JournalURLInPublicDOAJBuilder: 

3111 # ~~->$ JournalURLInPublicDOAJ:FormValidator~~ 

3112 @staticmethod 

3113 def render(settings, html_attrs): 

3114 # FIXME: not yet implemented in the front end, so setting here is speculative 

3115 html_attrs["data-parsley-journal-url-in-public-doaj"] = "" 

3116 

3117 @staticmethod 

3118 def wtforms(field, settings): 

3119 return JournalURLInPublicDOAJ(message=settings.get("message")) 

3120 

3121 

3122class NoScriptTagBuilder: 

3123 # ~~->$ NoScriptTag:FormValidator 

3124 @staticmethod 

3125 def render(settings, html_attrs): 

3126 html_attrs["data-parsley-no-script-tag"] = "" 

3127 if "message" in settings: 

3128 html_attrs["data-parsley-no-script-tag-message"] = "<p><small>" + settings["message"] + "</small></p>" 

3129 else: 

3130 html_attrs["data-parsley-no-script-tag-message"] = "<p><small>" + lazy_gettext("No script tags allowed") + "</p></small>" 

3131 

3132 @staticmethod 

3133 def wtforms(field, settings): 

3134 return NoScriptTag(settings.get("message", lazy_gettext("No script tags allowed"))) 

3135 

3136 

3137class OptionalIfBuilder: 

3138 # ~~->$ OptionalIf:FormValidator~~ 

3139 @staticmethod 

3140 def render(settings, html_attrs): 

3141 html_attrs["data-parsley-validate-if-empty"] = "true" 

3142 html_attrs["data-parsley-optional-if"] = settings.get("field") 

3143 html_attrs["data-parsley-optional-if-message"] = "<p><small>" + settings.get("message") + "</p></small>" 

3144 

3145 @staticmethod 

3146 def wtforms(field, settings): 

3147 return OptionalIf(settings.get("field") or field, settings.get("message"), settings.get("values", [])) 

3148 

3149 

3150class IsISSNBuilder: 

3151 # ~~->$ IsISSN:FormValidator~~ 

3152 @staticmethod 

3153 def render(settings, html_attrs): 

3154 html_attrs["pattern"] = ISSN 

3155 html_attrs["data-parsley-pattern"] = ISSN 

3156 html_attrs["data-parsley-pattern-message"] = settings.get("message") 

3157 

3158 @staticmethod 

3159 def wtforms(field, settings): 

3160 return validators.Regexp(regex=ISSN_COMPILED, message=settings.get("message")) 

3161 

3162 

3163class IsISSNListBuilder: 

3164 # ~~->$ IsISSNList:FormValidator~~ 

3165 @staticmethod 

3166 def render(settings, html_attrs): 

3167 html_attrs["data-parsley-entry-pattern"] = ISSN 

3168 

3169 @staticmethod 

3170 def wtforms(field, settings): 

3171 return RegexpOnTagList(regex=ISSN_COMPILED, message=settings.get("message")) 

3172 

3173 

3174class DifferentToBuilder: 

3175 # ~~->$ DifferentTo:FormValidator~~ 

3176 @staticmethod 

3177 def render(settings, html_attrs): 

3178 html_attrs["data-parsley-different-to"] = settings.get("field") 

3179 html_attrs["data-parsley-different-to-message"] = "<p><small>" + settings.get("message") + "</small></p>" 

3180 

3181 @staticmethod 

3182 def wtforms(field, settings): 

3183 return DifferentTo(settings.get("field") or field, settings.get("ignore_empty", True), settings.get("message")) 

3184 

3185 

3186class RequiredIfBuilder: 

3187 # ~~->$ RequiredIf:FormValidator~~ 

3188 @staticmethod 

3189 def render(settings, html_attrs): 

3190 val = settings.get("value", "") 

3191 if isinstance(val, list): 

3192 val = ",".join(val) 

3193 

3194 if settings.get("skip_disabled"): 

3195 html_attrs["data-parsley-validate-if-disabled"] = "false" 

3196 

3197 html_attrs["data-parsley-validate-if-empty"] = "true" 

3198 html_attrs["data-parsley-required-if"] = val 

3199 

3200 ne = settings.get("not_empty", False) 

3201 if ne: 

3202 html_attrs["data-parsley-required-if-not-empty"] = "true" 

3203 

3204 html_attrs["data-parsley-required-if-field"] = settings.get("field") 

3205 if "message" in settings: 

3206 html_attrs["data-parsley-required-if-message"] = "<p><small>" + settings["message"] + "</small></p>" 

3207 else: 

3208 html_attrs["data-parsley-required-if-message"] = "<p><small>" + lazy_gettext("This answer is required") + "</small></p>" 

3209 

3210 @staticmethod 

3211 def wtforms(field, settings): 

3212 set_field = settings.get("field", field) 

3213 val = settings.get("value") 

3214 ne = settings.get("not_empty", False) 

3215 return RequiredIfOtherValue(set_field, val, ne, settings.get("message")) 

3216 

3217class StopValidationOnOtherValueBuilder: 

3218 # ~~->$ StopValidationOnOtherValue:FormValidator~~ 

3219 @staticmethod 

3220 def render(settings, html_attrs): 

3221 # no action required here, this is back-end only 

3222 return 

3223 

3224 @staticmethod 

3225 def wtforms(field, settings): 

3226 return StopValidationOnOtherValue(settings.get("field", field), settings.get("value")) 

3227 

3228class OnlyIfBuilder: 

3229 # ~~->$ OnlyIf:FormValidator~~ 

3230 @staticmethod 

3231 def render(settings, html_attrs): 

3232 html_attrs["data-parsley-only-if"] = ",".join([f["field"] for f in settings.get("fields", [])]) 

3233 for f in settings.get('fields'): 

3234 if "value" in f: 

3235 html_attrs["data-parsley-only-if-value_" + f["field"]] = f["value"] 

3236 if "not" in f: 

3237 html_attrs["data-parsley-only-if-not_" + f["field"]] = f["not"] 

3238 if "or" in f: 

3239 html_attrs["data-parsley-only-if-or_" + f["field"]] = ",".join(f["or"]) 

3240 html_attrs["data-parsley-only-if-message"] = settings.get("message") 

3241 

3242 @staticmethod 

3243 def wtforms(fields, settings): 

3244 return OnlyIf(other_fields=settings.get('fields') or fields, ignore_empty=settings.get('ignore_empty', True), 

3245 message=settings.get('message')) 

3246 

3247 

3248class OnlyIfExistsBuilder: 

3249 # ~~->$ OnlyIf:FormValidator~~ 

3250 @staticmethod 

3251 def render(settings, html_attrs): 

3252 html_attrs["data-parsley-only-if-exists"] = ",".join([f["field"] for f in settings.get("fields", [])]) 

3253 html_attrs["data-parsley-only-if-exists-message"] = "<p><small>" + settings.get("message") + "</small></p>" 

3254 

3255 @staticmethod 

3256 def wtforms(fields, settings): 

3257 return OnlyIfExists(other_fields=settings.get('fields') or fields, 

3258 ignore_empty=settings.get('ignore_empty', True), message=settings.get('message')) 

3259 

3260 

3261class NotIfBuildier: 

3262 # ~~->$ NotIf:FormValidator~~ 

3263 @staticmethod 

3264 def render(settings, html_attrs): 

3265 html_attrs["data-parsley-not-if"] = ",".join([f.get("field") for f in settings.get("fields", [])]) 

3266 if settings.get("message"): 

3267 html_attrs["data-parsley-not-if-message"] = settings.get("message") 

3268 

3269 @staticmethod 

3270 def wtforms(fields, settings): 

3271 return NotIf(settings.get('fields') or fields, settings.get('message')) 

3272 

3273 

3274class GroupMemberBuilder: 

3275 # ~~->$ GroupMember:FormValidator~~ 

3276 @staticmethod 

3277 def render(settings, html_attrs): 

3278 # FIXME: front end validator for this does not yet exist (do we have an existing one from formcontext?) 

3279 html_attrs["data-parsley-group-member-field"] = settings.get("group_field") 

3280 

3281 @staticmethod 

3282 def wtforms(field, settings): 

3283 return GroupMember(settings.get('group_field') or field) 

3284 

3285 

3286class RequiredValueBuilder: 

3287 # ~~->$ RequiredValue:FormValidator~~ 

3288 @staticmethod 

3289 def render(settings, html_attrs): 

3290 html_attrs["data-parsley-requiredvalue"] = settings.get("value") 

3291 

3292 @staticmethod 

3293 def wtforms(field, settings): 

3294 return RequiredValue(settings.get("value"), settings.get("message")) 

3295 

3296 

3297class BigEndDateBuilder: 

3298 # ~~->$ BigEndDate:FormValidator~~ 

3299 @staticmethod 

3300 def render(settings, html_attrs): 

3301 html_attrs["data-parsley-validdate"] = "" 

3302 ignore_empty = settings.get("ignore_empty", False) 

3303 html_attrs["data-parsley-validdate-ignore_empty"] = "true" if ignore_empty else "false" 

3304 html_attrs["data-parsley-pattern-message"] = settings.get("message") 

3305 

3306 @staticmethod 

3307 def wtforms(field, settings): 

3308 return BigEndDate(settings.get("message")) 

3309 

3310class DateInThePastBuilder: 

3311 # ~~->$ BigEndDate:FormValidator~~ 

3312 @staticmethod 

3313 def render(settings, html_attrs): 

3314 # no client side rendering for this, as it interferes with the datepicker 

3315 pass 

3316 

3317 @staticmethod 

3318 def wtforms(field, settings): 

3319 return DateInThePast(settings.get("message")) 

3320 

3321class YearBuilder: 

3322 @staticmethod 

3323 def render(settings, html_attrs): 

3324 html_attrs["data-parsley-year"] = app.config.get('MINIMAL_OA_START_DATE', 1900) 

3325 html_attrs["data-parsley-year-message"] = "<p><small>" + settings["message"] + "</small></p>" 

3326 

3327 @staticmethod 

3328 def wtforms(field, settings): 

3329 return Year(settings.get("message")) 

3330 

3331 

3332class CurrentISOCurrencyBuilder: 

3333 @staticmethod 

3334 def render(settings, html_attrs): 

3335 pass 

3336 

3337 @staticmethod 

3338 def wtforms(field, settings): 

3339 return CurrentISOCurrency(settings.get("message")) 

3340 

3341 

3342class CurrentISOLanguageBuilder: 

3343 @staticmethod 

3344 def render(settings, html_attrs): 

3345 pass 

3346 

3347 @staticmethod 

3348 def wtforms(field, settings): 

3349 return CurrentISOLanguage(settings.get("message")) 

3350 

3351 

3352class NotValueBuilder: 

3353 # ~~->$ NotValue:FormValidator~~ 

3354 @staticmethod 

3355 def render(settings, html_attrs): 

3356 html_attrs["data-parsley-not-value"] = settings.get("value", "") 

3357 if "message" in settings: 

3358 html_attrs["data-parsley-not-value-message"] = "<p><small>" + settings["message"] + "</small></p>" 

3359 

3360 @staticmethod 

3361 def wtforms(field, settings): 

3362 return NotValue(settings.get("value"), settings.get("message")) 

3363 

3364 

3365class ForbiddenWordBuilder: 

3366 # ~~->$ ForbiddenWord:FormValidator~~ 

3367 @staticmethod 

3368 def render(settings, html_attrs): 

3369 word = settings.get("word", "") 

3370 if word: 

3371 # Use Parsley's built-in pattern validator with a case-insensitive negative lookahead. 

3372 # The /i flag is picked up by Parsley's regexp parser via the /pattern/i literal format. 

3373 html_attrs["data-parsley-pattern"] = "/^(?!.*" + word + ").*$/i" 

3374 if "message" in settings and word: 

3375 html_attrs["data-parsley-pattern-message"] = "<p><small>" + settings["message"] + "</small></p>" 

3376 

3377 @staticmethod 

3378 def wtforms(field, settings): 

3379 return ForbiddenWord(settings.get("word"), settings.get("message")) 

3380 

3381 

3382######################################################### 

3383# Crosswalks 

3384######################################################### 

3385 

3386PYTHON_FUNCTIONS = { 

3387 "options": { 

3388 "iso_country_list": iso_country_list, 

3389 "iso_language_list": iso_language_list, 

3390 "iso_currency_list": iso_currency_list, 

3391 "quick_reject": quick_reject, 

3392 "application_statuses": application_statuses, 

3393 "editor_choices": editor_choices 

3394 }, 

3395 "disabled": { 

3396 "application_status_disabled": application_status_disabled, 

3397 "disable_edit_note_except_editing_user": disable_edit_note_except_editing_user, 

3398 "disable_edit_flag_except_author_admin_assignee": disable_edit_flag_except_author_admin_assignee 

3399 }, 

3400 "merge_disabled": { 

3401 "merge_disabled_notes": merge_disabled_notes 

3402 }, 

3403 "validate": { 

3404 "render": { 

3405 "required": RequiredBuilder.render, 

3406 "required_if_active": RequiredIfActiveBuilder.render, 

3407 "is_url": IsURLBuilder.render, 

3408 "int_range": IntRangeBuilder.render, 

3409 "issn_in_public_doaj": ISSNInPublicDOAJBuilder.render, 

3410 "journal_url_in_public_doaj": JournalURLInPublicDOAJBuilder.render, 

3411 "optional_if": OptionalIfBuilder.render, 

3412 "is_issn": IsISSNBuilder.render, 

3413 "is_issn_list": IsISSNListBuilder.render, 

3414 "different_to": DifferentToBuilder.render, 

3415 "required_if": RequiredIfBuilder.render, 

3416 "only_if": OnlyIfBuilder.render, 

3417 "only_if_exists": OnlyIfExistsBuilder.render, 

3418 "group_member": GroupMemberBuilder.render, 

3419 "not_if": NotIfBuildier.render, 

3420 "required_value": RequiredValueBuilder.render, 

3421 "bigenddate": BigEndDateBuilder.render, 

3422 "no_script_tag": NoScriptTagBuilder.render, 

3423 "year": YearBuilder.render, 

3424 "date_in_the_past": DateInThePastBuilder.render, 

3425 "not_value": NotValueBuilder.render, 

3426 "forbidden_word": ForbiddenWordBuilder.render, 

3427 "stop_validation_on_other_value": StopValidationOnOtherValueBuilder.render, 

3428 }, 

3429 "wtforms": { 

3430 "required": RequiredBuilder.wtforms, 

3431 "required_if_active": RequiredIfActiveBuilder.wtforms, 

3432 "is_url": IsURLBuilder.wtforms, 

3433 "max_tags": MaxTagsBuilder.wtforms, 

3434 "int_range": IntRangeBuilder.wtforms, 

3435 "stop_words": StopWordsBuilder.wtforms, 

3436 "issn_in_public_doaj": ISSNInPublicDOAJBuilder.wtforms, 

3437 "journal_url_in_public_doaj": JournalURLInPublicDOAJBuilder.wtforms, 

3438 "optional_if": OptionalIfBuilder.wtforms, 

3439 "is_issn": IsISSNBuilder.wtforms, 

3440 "is_issn_list": IsISSNListBuilder.wtforms, 

3441 "different_to": DifferentToBuilder.wtforms, 

3442 "required_if": RequiredIfBuilder.wtforms, 

3443 "only_if": OnlyIfBuilder.wtforms, 

3444 "only_if_exists": OnlyIfExistsBuilder.wtforms, 

3445 "group_member": GroupMemberBuilder.wtforms, 

3446 "not_if": NotIfBuildier.wtforms, 

3447 "required_value": RequiredValueBuilder.wtforms, 

3448 "bigenddate": BigEndDateBuilder.wtforms, 

3449 "reserved_usernames": ReservedUsernamesBuilder.wtforms, 

3450 "owner_exists": OwnerExistsBuilder.wtforms, 

3451 "no_script_tag": NoScriptTagBuilder.wtforms, 

3452 "year": YearBuilder.wtforms, 

3453 "current_iso_currency": CurrentISOCurrencyBuilder.wtforms, 

3454 "current_iso_language": CurrentISOLanguageBuilder.wtforms, 

3455 "date_in_the_past": DateInThePastBuilder.wtforms, 

3456 "not_value": NotValueBuilder.wtforms, 

3457 "forbidden_word": ForbiddenWordBuilder.wtforms, 

3458 "stop_validation_on_other_value": StopValidationOnOtherValueBuilder.wtforms 

3459 } 

3460 } 

3461} 

3462 

3463JAVASCRIPT_FUNCTIONS = { 

3464 "clickable_url": "formulaic.widgets.newClickableUrl", # ~~-> ClickableURL:FormWidget~~ 

3465 "click_to_copy": "formulaic.widgets.newClickToCopy", # ~~-> ClickToCopy:FormWidget~~ 

3466 "clickable_owner": "formulaic.widgets.newClickableOwner", # ~~-> ClickableOwner:FormWidget~~ 

3467 "select": "formulaic.widgets.newSelect", # ~~-> SelectBox:FormWidget~~ 

3468 "taglist": "formulaic.widgets.newTagList", # ~~-> TagList:FormWidget~~ 

3469 "tagentry": "formulaic.widgets.newTagEntry", # ~~-> TagEntry:FormWidget~~ 

3470 "multiple_field": "formulaic.widgets.newMultipleField", # ~~-> MultiField:FormWidget~~ 

3471 "infinite_repeat": "formulaic.widgets.newInfiniteRepeat", # ~~-> InfiniteRepeat:FormWidget~~ 

3472 "autocomplete": "formulaic.widgets.newAutocomplete", # ~~-> Autocomplete:FormWidget~~ 

3473 "subject_tree": "formulaic.widgets.newSubjectTree", # ~~-> SubjectTree:FormWidget~~ 

3474 "full_contents": "formulaic.widgets.newFullContents", # ~~^->FullContents:FormWidget~~ 

3475 "load_editors": "formulaic.widgets.newLoadEditors", # ~~-> LoadEditors:FormWidget~~ 

3476 "trim_whitespace": "formulaic.widgets.newTrimWhitespace", # ~~-> TrimWhitespace:FormWidget~~ 

3477 "note_modal": "formulaic.widgets.newNoteModal", # ~~-> NoteModal:FormWidget~~, 

3478 "autocheck": "formulaic.widgets.newAutocheck", # ~~-> Autocheck:FormWidget~~ 

3479 "issn_link": "formulaic.widgets.newIssnLink", # ~~-> IssnLink:FormWidget~~, 

3480 "article_info": "formulaic.widgets.newArticleInfo", # ~~-> ArticleInfo:FormWidget~~ 

3481 "flag_manager": "formulaic.widgets.newFlagManager", # ~~-> FlagManager:FormWidget~~ 

3482 "date_picker": "formulaic.widgets.newDatePicker", # ~~-> DatePicker:FormWidget~~ 

3483 "preassessment_checklist": "formulaic.widgets.newPreassessmentChecklist" # ~~-> PreassessmentChecklist:FormWidget~~ 

3484 

3485} 

3486 

3487 

3488############################################################## 

3489# A couple of convenient widgets for WTForms rendering 

3490############################################################## 

3491 

3492class NumberWidget(widgets.Input): 

3493 input_type = 'number' 

3494 

3495class FieldsetWidget(object): 

3496 """ 

3497 Renders a fieldset with a legend 

3498 if legend_display is true the question is displayed 

3499 if legend_display is false it is for screen readers only 

3500 """ 

3501 def __init__(self, legend, sr_only_label = True, prefix_label=False): 

3502 self.sr_only = sr_only_label 

3503 self.prefix_label = prefix_label 

3504 

3505 self.legend = f'<legend ' 

3506 if self.sr_only: 

3507 self.legend += f'class="sr-only"' 

3508 self.legend += f'>{legend}</legend>' 

3509 

3510 self.html_wrapper = f"<fieldset> {self.legend} [BODY]</fieldset>" 

3511 

3512 def __call__(self, field, **kwargs): 

3513 fields = '' 

3514 for subfield in field: 

3515 fields += f'{subfield.label}{subfield(**kwargs)}' if self.prefix_label else f'{subfield(**kwargs)}{subfield.label}' 

3516 

3517 html = self.html_wrapper.replace("[BODY]", fields) 

3518 return HTMLString(''.join(html)) 

3519 

3520 

3521class ListWidgetWithSubfields(object): 

3522 """ 

3523 Renders a list of fields as a `ul` or `ol` list. 

3524 

3525 This is used for fields which encapsulate many inner fields as subfields. 

3526 The widget will try to iterate the field to get access to the subfields and 

3527 call them to render them. 

3528 

3529 If `prefix_label` is set, the subfield's label is printed before the field, 

3530 otherwise afterwards. The latter is useful for iterating radios or 

3531 checkboxes. 

3532 """ 

3533 

3534 def __init__(self, html_tag='ul', prefix_label=False): 

3535 assert html_tag in ('ol', 'ul') 

3536 self.html_tag = html_tag 

3537 self.prefix_label = prefix_label 

3538 

3539 def __call__(self, field, **kwargs): 

3540 # kwargs.setdefault('id', field.id) 

3541 fl = kwargs.pop("formulaic", None) 

3542 html = ['<%s %s>' % (self.html_tag, html_params(**kwargs))] 

3543 for subfield in field: 

3544 if self.prefix_label: 

3545 html.append('<li tabindex=0>%s %s' % (subfield.label, subfield(**kwargs))) 

3546 else: 

3547 label = str(subfield.label) 

3548 html.append('<li tabindex=0>%s %s' % (subfield(**kwargs), label)) 

3549 

3550 html.append("</li>") 

3551 

3552 html.append('</%s>' % self.html_tag) 

3553 return HTMLString(''.join(html)) 

3554 

3555 

3556class RepeatableFieldListWidget(object): 

3557 """ 

3558 Renders a repeatable single-value field (FieldList of e.g. StringField, 

3559 DateField, TextAreaField or SelectField) as a `ul` list. 

3560 

3561 WTForms' stock ListWidget (the default widget for FieldList) only ever 

3562 applies the HTML attributes it's called with to the wrapping `<ul>`, not 

3563 to the individual subfields it renders - so attributes generated from a 

3564 field's `validate` config (e.g. `data-parsley-not-value`, 

3565 `data-parsley-required-if`) never reached the actual `<input>` elements, 

3566 and Parsley silently skipped validating them. This widget applies those 

3567 same attributes to each subfield too, while leaving the `<ul>` itself 

3568 unchanged, and without clobbering each subfield's own unique id/name. 

3569 

3570 Only the first entry represents the field's "at least one" requirement; 

3571 every later entry is an optional extra the user may leave blank (see 

3572 formulaic.js, which already strips the plain `required` attribute from 

3573 entries after the first for this exact reason). So a `required_if` rule 

3574 is applied to the first entry only - carrying it over to the later, 

3575 usually-empty-and-hidden entries would make Parsley block navigation 

3576 over a field the user was never asked to fill in. 

3577 """ 

3578 

3579 def __init__(self, html_tag='ul', prefix_label=True): 

3580 assert html_tag in ('ol', 'ul') 

3581 self.html_tag = html_tag 

3582 self.prefix_label = prefix_label 

3583 

3584 def __call__(self, field, **kwargs): 

3585 kwargs.pop("formulaic", None) 

3586 container_attrs = dict(kwargs) 

3587 container_attrs.setdefault('id', field.id) 

3588 later_entry_kwargs = {k: v for k, v in kwargs.items() if not k.startswith("data-parsley-required-if")} 

3589 

3590 html = ['<%s %s>' % (self.html_tag, html_params(**container_attrs))] 

3591 for idx, subfield in enumerate(field): 

3592 subfield_kwargs = kwargs if idx == 0 else later_entry_kwargs 

3593 if self.prefix_label: 

3594 html.append('<li>%s %s</li>' % (subfield.label, subfield(**subfield_kwargs))) 

3595 else: 

3596 html.append('<li>%s %s</li>' % (subfield(**subfield_kwargs), subfield.label)) 

3597 html.append('</%s>' % self.html_tag) 

3598 return HTMLString(''.join(html)) 

3599 

3600 

3601########################################################## 

3602# Mapping from configurations to WTForms builders 

3603########################################################## 

3604 

3605class RadioBuilder(WTFormsBuilder): 

3606 @staticmethod 

3607 def match(field): 

3608 return field.get("input") == "radio" 

3609 

3610 @staticmethod 

3611 def wtform(formulaic_context, field, wtfargs): 

3612 # wtfargs["widget"] = ListWidgetWithSubfields() 

3613 wtfargs["widget"] = FieldsetWidget(legend=field.get("label"), sr_only_label=True) 

3614 return UnconstrainedRadioField(**wtfargs) 

3615 

3616 

3617class MultiCheckboxBuilder(WTFormsBuilder): 

3618 @staticmethod 

3619 def match(field): 

3620 return field.get("input") == "checkbox" and \ 

3621 (len(field.get("options", [])) > 0 or field.get("options_fn") is not None) 

3622 

3623 @staticmethod 

3624 def wtform(formulaic_context, field, wtfargs): 

3625 wtfargs["option_widget"] = widgets.CheckboxInput() 

3626 wtfargs["widget"] = ListWidgetWithSubfields() 

3627 return SelectMultipleField(**wtfargs) 

3628 

3629 

3630class SingleCheckboxBuilder(WTFormsBuilder): 

3631 @staticmethod 

3632 def match(field): 

3633 return field.get("input") == "checkbox" and len(field.get("options", [])) == 0 and field.get( 

3634 "options_fn") is None 

3635 

3636 @staticmethod 

3637 def wtform(formulaic_context, field, wtfargs): 

3638 return BooleanField(**wtfargs) 

3639 

3640 

3641class SelectBuilder(WTFormsBuilder): 

3642 @staticmethod 

3643 def match(field): 

3644 return field.get("input") == "select" and not field.get("multiple", False) 

3645 

3646 @staticmethod 

3647 def wtform(formulaic_context, field, wtfargs): 

3648 if field.get("repeatable", {}).get("label", ""): 

3649 wtfargs['label'] = field["repeatable"]["label"] 

3650 sf = SelectField(**wtfargs) 

3651 if "repeatable" in field: 

3652 sf = FieldList(sf, min_entries=field.get("repeatable", {}).get("initial", 1), 

3653 widget=RepeatableFieldListWidget()) 

3654 

3655 return sf 

3656 

3657 

3658class MultiSelectBuilder(WTFormsBuilder): 

3659 @staticmethod 

3660 def match(field): 

3661 return field.get("input") == "select" and field.get("multiple", False) 

3662 

3663 @staticmethod 

3664 def wtform(formulaic_context, field, wtfargs): 

3665 return SelectMultipleField(**wtfargs) 

3666 

3667 

3668class TextBuilder(WTFormsBuilder): 

3669 @staticmethod 

3670 def match(field): 

3671 return field.get("input") == "text" 

3672 

3673 @staticmethod 

3674 def wtform(formulaic_context, field, wtfargs): 

3675 if "filters" not in wtfargs: 

3676 wtfargs["filters"] = (lambda x: x.strip() if x is not None else x,) 

3677 sf = StringField(**wtfargs) 

3678 if "repeatable" in field: 

3679 sf = FieldList(sf, min_entries=field.get("repeatable", {}).get("initial", 1), 

3680 widget=RepeatableFieldListWidget()) 

3681 return sf 

3682 

3683class DateBuilder(WTFormsBuilder): 

3684 @staticmethod 

3685 def match(field): 

3686 return field.get("input") == "date" 

3687 

3688 @staticmethod 

3689 def wtform(formulaic_context, field, wtfargs): 

3690 wtfargs["widget"] = widgets.Input(input_type="date") 

3691 sf = DateField(**wtfargs) 

3692 if "repeatable" in field: 

3693 sf = FieldList(sf, min_entries=field.get("repeatable", {}).get("initial", 1), 

3694 widget=RepeatableFieldListWidget()) 

3695 return sf 

3696 

3697class TextAreaBuilder(WTFormsBuilder): 

3698 @staticmethod 

3699 def match(field): 

3700 return field.get("input") == "textarea" 

3701 

3702 @staticmethod 

3703 def wtform(formulaic_context, field, wtfargs): 

3704 sf = TextAreaField(**wtfargs) 

3705 if "repeatable" in field: 

3706 sf = FieldList(sf, min_entries=field.get("repeatable", {}).get("initial", 1), 

3707 widget=RepeatableFieldListWidget()) 

3708 return sf 

3709 

3710 

3711class TagListBuilder(WTFormsBuilder): 

3712 @staticmethod 

3713 def match(field): 

3714 return field.get("input") == "taglist" 

3715 

3716 @staticmethod 

3717 def wtform(formulaic_context, field, wtfargs): 

3718 return TagListField(**wtfargs) 

3719 

3720 

3721class IntegerBuilder(WTFormsBuilder): 

3722 @staticmethod 

3723 def match(field): 

3724 return field.get("input") == "number" and field.get("datatype") == "integer" 

3725 

3726 @staticmethod 

3727 def wtform(formulaic_context, field, wtfargs): 

3728 wtfargs["widget"] = NumberWidget() 

3729 return IntegerField(**wtfargs) 

3730 

3731 

3732# TODO: multiple group doesn't work 

3733class GroupBuilder(WTFormsBuilder): 

3734 @staticmethod 

3735 def match(field): 

3736 return field.get("input") == "group" and field.get("repeatable") is None 

3737 

3738 @staticmethod 

3739 def wtform(formulaic_context, field, wtfargs): 

3740 fields = [formulaic_context.get(subfield) for subfield in field.get("subfields", [])] 

3741 klazz = formulaic_context.make_wtform_class(fields) 

3742 return NestedFormField(klazz) 

3743 

3744 

3745class GroupListBuilder(WTFormsBuilder): 

3746 @staticmethod 

3747 def match(field): 

3748 return field.get("input") == "group" and field.get("repeatable") is not None 

3749 

3750 @staticmethod 

3751 def wtform(formulaic_context, field, wtfargs): 

3752 ff = GroupBuilder.wtform(formulaic_context, field, wtfargs) 

3753 repeat_cfg = field.get("repeatable", {}) 

3754 return FieldList(ff, min_entries=repeat_cfg.get("initial", 1)) 

3755 

3756 

3757class HiddenFieldBuilder(WTFormsBuilder): 

3758 @staticmethod 

3759 def match(field): 

3760 return field.get("input") == "hidden" 

3761 

3762 @staticmethod 

3763 def wtform(formulaic_context, field, wtfargs): 

3764 return HiddenField(**wtfargs) 

3765 

3766 

3767WTFORMS_BUILDERS = [ 

3768 RadioBuilder, 

3769 MultiCheckboxBuilder, 

3770 SingleCheckboxBuilder, 

3771 SelectBuilder, 

3772 MultiSelectBuilder, 

3773 TextBuilder, 

3774 TextAreaBuilder, 

3775 TagListBuilder, 

3776 IntegerBuilder, 

3777 GroupBuilder, 

3778 GroupListBuilder, 

3779 HiddenFieldBuilder, 

3780 DateBuilder 

3781] 

3782 

3783ApplicationFormFactory = Formulaic(APPLICATION_FORMS, WTFORMS_BUILDERS, function_map=PYTHON_FUNCTIONS, 

3784 javascript_functions=JAVASCRIPT_FUNCTIONS) 

3785JournalFormFactory = Formulaic(JOURNAL_FORMS, WTFORMS_BUILDERS, function_map=PYTHON_FUNCTIONS, 

3786 javascript_functions=JAVASCRIPT_FUNCTIONS) 

3787 

3788if __name__ == "__main__": 

3789 """ 

3790 Running this file from the command line enables you to output documentation for a given form context. 

3791 

3792 See `docs/forms.sh` for where this is used 

3793 

3794 To create the documentation you can call this file with 3 arguments: 

3795 

3796 -t - the object type to output. Either 'journal' or 'application' 

3797 -c - the form context. Will be one of the contexts defined elsewhere in this file, which may be specific to the 

3798 object type. For example, 'admin' or 'editor' 

3799 -o - the path to the file where to output the result 

3800 

3801 The output is a CSV which lists the following information: 

3802 

3803 * Form Position - the position in the form. Felds are listed in order 

3804 * Field Name - the form field name 

3805 * Label - the form field label 

3806 * Input Type - what kind of input (e.g. radio, text) 

3807 * Options - the express options allowed, or the name of the function which generates the options 

3808 * Disabled? - is the field disabled in this context 

3809 * Fieldset ID - the ID (from this file) of the fieldset that this field is part of 

3810 """ 

3811 import argparse 

3812 

3813 parser = argparse.ArgumentParser() 

3814 parser.add_argument("-t", "--type", help="object type to output") 

3815 parser.add_argument("-c", "--context", help="context to output") 

3816 parser.add_argument("-o", "--out", help="output file path") 

3817 args = parser.parse_args() 

3818 

3819 if not args.out: 

3820 print("Please specify an output file path with the -o option") 

3821 parser.print_help() 

3822 exit() 

3823 

3824 if not args.context: 

3825 print("Please specify a context to output") 

3826 parser.print_help() 

3827 exit() 

3828 

3829 if not args.type: 

3830 print("Please specify a type to output") 

3831 parser.print_help() 

3832 exit() 

3833 

3834 fc = None 

3835 if args.type == "journal": 

3836 fc = JournalFormFactory.context(args.context) 

3837 elif args.type == "application": 

3838 fc = ApplicationFormFactory.context(args.context) 

3839 

3840 if fc is not None: 

3841 fc.to_summary_csv(args.out) 

3842 else: 

3843 print("You did not enter a valid type. Use one of 'journal' or 'application'")