Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Compare revisions
aee91e223b6edf7ad3a51bf1d22f2ea774584ed1 to cb9aa8f4907ee750c6030a71173ceed20c83c345
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
tddd96-grupp11/teknikattan-scoring-system
Select target project
No results found
cb9aa8f4907ee750c6030a71173ceed20c83c345
Select Git revision
Swap
Target
tddd96-grupp11/teknikattan-scoring-system
Select target project
tddd96-grupp11/teknikattan-scoring-system
1 result
aee91e223b6edf7ad3a51bf1d22f2ea774584ed1
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/app/database/__init__.py
+1
-1
1 addition, 1 deletion
server/app/database/__init__.py
server/app/database/controller/edit.py
+22
-124
22 additions, 124 deletions
server/app/database/controller/edit.py
with
23 additions
and
125 deletions
server/app/database/__init__.py
View file @
cb9aa8f4
...
...
@@ -45,7 +45,7 @@ class Dictionary(TypeDecorator):
def
process_bind_param
(
self
,
value
,
dialect
):
if
value
is
not
None
:
value
=
json
.
dumps
(
value
)
.
replace
(
"'"
,
'"'
)
value
=
json
.
dumps
(
value
)
return
value
...
...
This diff is collapsed.
Click to expand it.
server/app/database/controller/edit.py
View file @
cb9aa8f4
...
...
@@ -26,130 +26,28 @@ def switch_order(item1, item2):
return
item1
def
component
(
item
,
x
,
y
,
w
,
h
,
data
):
"""
Edits position, size and content of the provided component.
"""
if
x
:
item
.
x
=
x
if
y
:
item
.
y
=
y
if
w
:
item
.
w
=
w
if
h
:
item
.
h
=
h
if
data
:
item
.
data
=
data
db
.
session
.
commit
()
db
.
session
.
refresh
(
item
)
return
item
def
slide
(
item
,
title
=
None
,
timer
=
None
):
"""
Edits the title and timer of the slide.
"""
if
title
:
item
.
title
=
title
if
timer
:
item
.
timer
=
timer
db
.
session
.
commit
()
db
.
session
.
refresh
(
item
)
return
item
def
team
(
item_team
,
name
=
None
,
competition_id
=
None
):
"""
Edits the name and competition of the team.
"""
if
name
:
item_team
.
name
=
name
if
competition_id
:
item_team
.
competition_id
=
competition_id
db
.
session
.
commit
()
db
.
session
.
refresh
(
item_team
)
return
item_team
def
competition
(
item
,
name
=
None
,
year
=
None
,
city_id
=
None
):
"""
Edits the name and year of the competition.
"""
if
name
:
item
.
name
=
name
if
year
:
item
.
year
=
year
if
city_id
:
item
.
city_id
=
city_id
db
.
session
.
commit
()
db
.
session
.
refresh
(
item
)
return
item
def
user
(
item
,
name
=
None
,
email
=
None
,
city_id
=
None
,
role_id
=
None
):
"""
Edits the name, email, city and role of the user.
"""
if
name
:
item
.
name
=
name
.
title
()
if
email
:
item
.
email
=
email
if
city_id
:
item
.
city_id
=
city_id
if
role_id
:
item
.
role_id
=
role_id
def
default
(
item
,
**
kwargs
):
"""
For every keyword argument, set that attribute on item to the given value.
Raise error if item doesn
'
t already have that attribute. Do nothing if the
value for a given key is None. Works for any type of item.
Example:
>>>
user
=
default
(
user
,
name
=
"
Karl Karlsson
"
)
# Change name
>>>
user
.
name
Karl
Karlsson
>>>
user
=
default
(
user
,
efternamn
=
"
Jönsson
"
)
# Try to set attribute that doesn't exist
AttributeError
:
Item
of
type
<
class
'
app
.
database
.
models
.
User
'
> has no attribute
'
efternamn
'
>>>
user
=
default
(
user
,
name
=
None
)
# Nothing happens if value is None
>>>
user
.
name
Karl
Karlsson
"""
for key, value in kwargs.items():
if not hasattr(item, key):
raise AttributeError(f
"
Item of type {type(item)} has no attribute
'
{
key
}
'"
)
if value is not None:
setattr(item, key, value)
db.session.commit()
db.session.refresh(item)
return item
def
question
(
item_question
,
name
=
None
,
total_score
=
None
,
type_id
=
None
,
slide_id
=
None
):
"""
Edits the name, score, type and slide of the question.
"""
if
name
:
item_question
.
name
=
name
if
total_score
:
item_question
.
total_score
=
total_score
if
type_id
:
item_question
.
type_id
=
type_id
if
slide_id
:
item_question
.
slide_id
=
slide_id
db
.
session
.
commit
()
db
.
session
.
refresh
(
item_question
)
return
item_question
def
question_alternative
(
item
,
text
=
None
,
value
=
None
):
if
text
:
item
.
text
=
text
if
value
:
item
.
value
=
value
db
.
session
.
commit
()
db
.
session
.
refresh
(
item
)
return
item
def
question_answer
(
item
,
data
=
None
,
score
=
None
):
if
data
:
item
.
data
=
data
if
score
:
item
.
score
=
score
db
.
session
.
commit
()
db
.
session
.
refresh
(
item
)
return
item
This diff is collapsed.
Click to expand it.
Prev
1
2
Next