Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
ValUnifer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IPIPAN
ValUnifer
Commits
addfd246
Commit
addfd246
authored
2 years ago
by
dcz
Browse files
Options
Downloads
Patches
Plain Diff
Additional fitlers for unified frames
parent
2a2e5ee1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
entries/forms.py
+15
-0
15 additions, 0 deletions
entries/forms.py
importer/unification/UnifiedFrameImport.py
+4
-0
4 additions, 0 deletions
importer/unification/UnifiedFrameImport.py
unifier/models.py
+18
-0
18 additions, 0 deletions
unifier/models.py
unifier/views.py
+5
-0
5 additions, 0 deletions
unifier/views.py
with
42 additions
and
0 deletions
entries/forms.py
+
15
−
0
View file @
addfd246
...
...
@@ -628,6 +628,13 @@ class UnifiedFrameFormFactory(FormFactory):
lookup
=
'
arguments_count
'
,
),
None
),
(
'
num_frames
'
,
lambda
:
RangeFilter
(
label
=
_
(
'
Liczba ram semantycznych
'
),
lookup
=
'
slowal_frames_count
'
,
),
None
),
(
'
name
'
,
lambda
:
RegexFilter
(
...
...
@@ -636,6 +643,14 @@ class UnifiedFrameFormFactory(FormFactory):
lookup
=
'
title
'
,
),
None
,
),
(
'
lemmas
'
,
lambda
:
RegexFilter
(
label
=
_
(
'
Lematy jednostek leksykalnych
'
),
max_length
=
200
,
lookup
=
'
unified_frame_2_slowal_frame__slowal_frame__lexical_units__base
'
,
),
None
,
),
(
None
,
None
,
lambda
n
,
cls
:
and_or_form_creator
(
_
(
'
UnifiedFrameArgument
'
),
'
add-argument-{}
'
.
format
(
n
),
data_add
=
'
argument
'
),
...
...
This diff is collapsed.
Click to expand it.
importer/unification/UnifiedFrameImport.py
+
4
−
0
View file @
addfd246
...
...
@@ -86,5 +86,9 @@ class UnifiedFrameImport:
if
subnode
.
_name
==
'
slowal_frame
'
:
UnifiedFrameImport
.
storeSlowalFrame
(
subnode
,
unifiedFrame
,
argumentIdsMapping
)
unifiedFrame
.
arguments_count
=
len
(
argumentIdsMapping
)
unifiedFrame
.
update_sloval_frame_count
()
unifiedFrame
.
save
()
return
unifiedFrame
.
pk
This diff is collapsed.
Click to expand it.
unifier/models.py
+
18
−
0
View file @
addfd246
...
...
@@ -27,6 +27,10 @@ class UnifiedFrame(models.Model):
assignments
=
GenericRelation
(
"
users.Assignment
"
,
content_type_field
=
"
subject_ct
"
,
object_id_field
=
"
subject_id
"
)
arguments_count
=
models
.
PositiveIntegerField
(
null
=
False
,
default
=
0
)
slowal_frames_count
=
models
.
PositiveIntegerField
(
null
=
False
,
default
=
0
)
objects
=
models
.
Manager
.
from_queryset
(
UnifiedFrameQueryset
)()
def
sorted_arguments
(
self
):
# TODO: zaimplementowac wlasciwe sortowanie
...
...
@@ -42,6 +46,7 @@ class UnifiedFrame(models.Model):
new_unified_frame_arguments
=
None
if
not
new_frame
:
new_frame
=
UnifiedFrame
.
objects
.
create
()
new_frame
.
arguments_count
=
self
.
arguments_count
new_frame
.
save
()
unified_frame_arguments
=
UnifiedFrameArgument
.
objects
.
filter
(
unified_frame
=
self
)
old_2_new_argument_mapping
=
{}
...
...
@@ -71,6 +76,10 @@ class UnifiedFrame(models.Model):
argument_mapping
.
unified_agrument_id
=
new_unified_frame_arguments
[
i
]
argument_mapping
.
save
()
self
.
update_sloval_frame_count
()
new_frame
.
update_sloval_frame_count
()
# curr_mapping = UnifiedFrame2SlowalFrameMapping.objects.filter(unified_frame=self).all()
# if len(curr_mapping) == 0:
# unified_frame_arguments = UnifiedFrameArgument.objects.filter(unified_frame=self).all()
...
...
@@ -79,11 +88,20 @@ class UnifiedFrame(models.Model):
return
new_frame
@transaction.atomic
def
update_sloval_frame_count
(
self
,
new_frame_title
:
Optional
=
None
)
->
"
UnifiedFrame
"
:
self
.
slowal_frames_count
=
self
.
unified_frame_2_slowal_frame
.
count
()
self
.
save
()
@transaction.atomic
def
duplicate
(
self
,
new_frame_title
:
Optional
=
None
)
->
"
UnifiedFrame
"
:
new_frame
=
UnifiedFrame
.
objects
.
create
(
title
=
new_frame_title
)
new_frame
.
arguments_count
=
self
.
arguments_count
new_frame
.
slowal_frames_count
=
self
.
slowal_frames_count
new_frame
.
save
()
unified_frame_arguments
=
UnifiedFrameArgument
.
objects
.
filter
(
unified_frame
=
self
)
for
unified_frame_argument
in
unified_frame_arguments
:
...
...
This diff is collapsed.
Click to expand it.
unifier/views.py
+
5
−
0
View file @
addfd246
...
...
@@ -375,6 +375,8 @@ def add_argument(request):
unifiedFrame
=
UnifiedFrame
.
objects
.
get
(
pk
=
unified_frame_id
)
newUnifiedFrameArgument
=
UnifiedFrameArgument
.
objects
.
create
(
unified_frame
=
unifiedFrame
)
newUnifiedFrameArgument
.
save
()
unifiedFrame
.
arguments_count
=
unifiedFrame
.
arguments_count
+
1
unifiedFrame
.
save
()
return
JsonResponse
({})
@ajax_required
...
...
@@ -386,6 +388,9 @@ def remove_argument(request):
newUnifiedFrameArgument
=
UnifiedFrameArgument
.
objects
.
get
(
id
=
complement_id
)
newUnifiedFrameArgument
.
delete
()
unifiedFrame
=
UnifiedFrame
.
objects
.
get
(
pk
=
unified_frame_id
)
unifiedFrame
.
arguments_count
=
unifiedFrame
.
arguments_count
-
1
unifiedFrame
.
save
()
return
JsonResponse
({})
@ajax_required
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment