Skip to content

Commit b961a85

Browse files
New classes: actor relation
1 parent 87f9ad3 commit b961a85

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

config/model/classes/actor.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
'properties': ['P11', 'P14', 'P22', 'P23'],
2929
'inverse': True,
3030
'multiple': True},
31+
'relation': {
32+
'label': _('relation'),
33+
'classes': 'person',
34+
'properties': 'OA7',
35+
'additional_fields': ['date']
36+
},
3137
'residence': {
3238
'label': _('residence'),
3339
'classes': 'object_location',
@@ -46,6 +52,10 @@
4652
'name', 'class', 'activity', 'involvement', 'first',
4753
'last', 'comment', 'update', 'remove'],
4854
'buttons': ['link']},
55+
'relation': {
56+
'additional_columns': ['remove'],
57+
'buttons': ['link']
58+
},
4959
'reference': standard_relations['reference']['tab'],
5060
'file': standard_relations['file']['tab'],
5161
'note': {}}}}

openatlas/forms/add_fields.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ def add_relations(form: Any, entity: Entity, origin: Entity | None) -> None:
171171
validators=validators))
172172

173173

174-
def add_date_fields(form_class: Any, entity: Entity) -> None:
175-
if 'date' not in entity.class_.attributes:
176-
return
174+
def add_date_fields(form_class: Any, entity: Optional[Entity] = None) -> None:
177175
validator_second = [OptionalValidator(), NumberRange(min=0, max=59)]
178176
validator_minute = [OptionalValidator(), NumberRange(min=0, max=59)]
179177
validator_hour = [OptionalValidator(), NumberRange(min=0, max=23)]

openatlas/forms/entity_form.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class Form(FlaskForm):
2424
add_types(Form, entity.class_)
2525
add_relations(Form, entity, origin)
2626
add_reference_systems(Form, entity.class_)
27-
add_date_fields(Form, entity)
27+
if 'date' in entity.class_.attributes:
28+
add_date_fields(Form, entity)
2829
add_description(Form, entity, origin)
2930
add_buttons(Form, entity)
3031
form: Any = Form(obj=entity)

openatlas/forms/form.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from openatlas.display.util import get_base_table_data
1616
from openatlas.display.util2 import show_table_icons, uc_first
1717
from openatlas.forms import manager, manager_base
18+
from openatlas.forms.add_fields import add_date_fields
1819
from openatlas.forms.field import (
1920
SubmitField, TableCidocField, TableField, TableMultiField, TreeField)
2021
from openatlas.models.entity import Entity, Link
@@ -77,6 +78,9 @@ class Form(FlaskForm):
7778
TableField(entities, validators=[InputRequired()]))
7879
for item in relation['additional_fields']:
7980
match item:
81+
case 'date':
82+
# Todo: what about time fields if already used there?
83+
add_date_fields(Form)
8084
case 'description' | 'page':
8185
setattr(Form, 'description', StringField(_(item)))
8286
setattr(Form, 'save', SubmitField(_('insert')))

0 commit comments

Comments
 (0)