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
Commits
5c128f38
Commit
5c128f38
authored
3 years ago
by
Josef Olsson
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation for dbc.get
parent
95cb52fe
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/app/apis/components.py
+1
-1
1 addition, 1 deletion
server/app/apis/components.py
server/app/apis/teams.py
+1
-1
1 addition, 1 deletion
server/app/apis/teams.py
server/app/database/controller/get.py
+50
-5
50 additions, 5 deletions
server/app/database/controller/get.py
with
52 additions
and
7 deletions
server/app/apis/components.py
+
1
−
1
View file @
5c128f38
...
...
@@ -25,7 +25,7 @@ class ComponentByID(Resource):
def
put
(
self
,
CID
,
SOrder
,
component_id
):
args
=
component_parser
.
parse_args
()
item
=
dbc
.
get
.
one
(
Component
,
component_id
)
item
=
dbc
.
edit
.
component
(
item
,
**
args
)
item
=
dbc
.
edit
.
component
(
item
,
**
args
)
return
item_response
(
schema
.
dump
(
item
))
@jwt_required
...
...
This diff is collapsed.
Click to expand it.
server/app/apis/teams.py
+
1
−
1
View file @
5c128f38
...
...
@@ -23,7 +23,7 @@ class TeamsList(Resource):
@jwt_required
def
post
(
self
,
CID
):
args
=
team_parser
.
parse_args
(
strict
=
True
)
item_comp
=
dbc
.
get
.
one
(
Competition
,
CID
)
item_comp
=
dbc
.
get
.
one
(
Competition
,
CID
)
item_team
=
dbc
.
add
.
team
(
args
[
"
name
"
],
item_comp
)
return
item_response
(
schema
.
dump
(
item_team
))
...
...
This diff is collapsed.
Click to expand it.
server/app/database/controller/get.py
+
50
−
5
View file @
5c128f38
"""
This file contains functionality to get data from the database.
"""
from
app.core
import
db
from
app.database.models
import
(
City
,
Code
,
Competition
,
Component
,
ComponentType
,
MediaType
,
Question
,
QuestionType
,
Role
,
Slide
,
Team
,
User
,
ViewType
)
from
app.database.models
import
(
City
,
Code
,
Competition
,
Component
,
ComponentType
,
MediaType
,
Question
,
QuestionType
,
Role
,
Slide
,
Team
,
User
,
ViewType
,
)
def
all
(
db_type
):
"""
Gets all elements in the provided table.
"""
return
db_type
.
query
.
all
()
def
one
(
db_type
,
id
,
required
=
True
,
error_msg
=
None
):
"""
Gets the element in the table that has the same id.
"""
return
db_type
.
query
.
filter
(
db_type
.
id
==
id
).
first_extended
(
required
,
error_msg
)
def
user_exists
(
email
):
"""
Checks if an user has that email.
"""
return
User
.
query
.
filter
(
User
.
email
==
email
).
count
()
>
0
def
code_by_code
(
code
):
"""
Gets the code object associated with the provided code.
"""
return
Code
.
query
.
filter
(
Code
.
code
==
code
.
upper
()).
first
()
def
user
(
UID
,
required
=
True
,
error_msg
=
None
):
"""
Gets the user object associated with the provided id.
"""
return
User
.
query
.
filter
(
User
.
id
==
UID
).
first_extended
(
required
,
error_msg
)
def
user_by_email
(
email
,
required
=
True
,
error_msg
=
None
):
"""
Gets the user object associated with the provided email.
"""
return
User
.
query
.
filter
(
User
.
email
==
email
).
first_extended
(
required
,
error_msg
)
def
slide
(
CID
,
SOrder
,
required
=
True
,
error_msg
=
None
):
"""
Gets the slide object associated with the provided id and order.
"""
filters
=
(
Slide
.
competition_id
==
CID
)
&
(
Slide
.
order
==
SOrder
)
return
Slide
.
query
.
filter
(
filters
).
first_extended
(
required
,
error_msg
)
def
team
(
CID
,
TID
,
required
=
True
,
error_msg
=
None
):
"""
Gets the team object associated with the provided id and competition id.
"""
return
Team
.
query
.
filter
((
Team
.
competition_id
==
CID
)
&
(
Team
.
id
==
TID
)).
first_extended
(
required
,
error_msg
)
def
question
(
CID
,
SOrder
,
QID
,
required
=
True
,
error_msg
=
None
):
"""
Gets the question object associated with the provided id, slide order and competition id.
"""
join_filters
=
(
Slide
.
competition_id
==
CID
)
&
(
Slide
.
order
==
SOrder
)
&
(
Slide
.
id
==
Question
.
slide_id
)
return
Question
.
query
.
join
(
Slide
,
join_filters
).
filter
(
Question
.
id
==
QID
).
first_extended
(
required
,
error_msg
)
def
code_list
(
competition_id
):
"""
Gets a list of all code objects associated with a the provided competition.
"""
team_view_id
=
1
join_filters
=
(
Code
.
view_type_id
==
team_view_id
)
&
(
Team
.
id
==
Code
.
pointer
)
filters
=
((
Code
.
view_type_id
!=
team_view_id
)
&
(
Code
.
pointer
==
competition_id
))(
...
...
@@ -53,22 +88,32 @@ def code_list(competition_id):
def
question_list
(
CID
):
"""
Gets a list of all question objects associated with a the provided competition.
"""
join_filters
=
(
Slide
.
competition_id
==
CID
)
&
(
Slide
.
id
==
Question
.
slide_id
)
return
Question
.
query
.
join
(
Slide
,
join_filters
).
all
()
def
component_list
(
CID
,
SOrder
):
"""
Gets a list of all component objects associated with a the provided competition id and slide order.
"""
join_filters
=
(
Slide
.
competition_id
==
CID
)
&
(
Slide
.
order
==
SOrder
)
&
(
Component
.
slide_id
==
Slide
.
id
)
return
Component
.
query
.
join
(
Slide
,
join_filters
).
all
()
def
team_list
(
CID
):
"""
Gets a list of all team objects associated with a the provided competition.
"""
return
Team
.
query
.
filter
(
Team
.
competition_id
==
CID
).
all
()
def
slide_list
(
CID
):
"""
Gets a list of all slide objects associated with a the provided competition.
"""
return
Slide
.
query
.
filter
(
Slide
.
competition_id
==
CID
).
all
()
def
slide_count
(
CID
):
"""
Gets the number of slides in the provided competition.
"""
return
Slide
.
query
.
filter
(
Slide
.
competition_id
==
CID
).
count
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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