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
8b50cff4
Commit
8b50cff4
authored
3 years ago
by
Josef Olsson
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation for dbc.delete
parent
27f86c26
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/package-lock.json
+1
-2
1 addition, 2 deletions
client/package-lock.json
server/app/database/controller/delete.py
+22
-0
22 additions, 0 deletions
server/app/database/controller/delete.py
with
23 additions
and
2 deletions
client/package-lock.json
+
1
−
2
View file @
8b50cff4
...
@@ -17239,8 +17239,7 @@
...
@@ -17239,8 +17239,7 @@
},
},
"ssri": {
"ssri": {
"version": "6.0.1",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz",
"resolved": "",
"integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==",
"requires": {
"requires": {
"figgy-pudding": "^3.5.1"
"figgy-pudding": "^3.5.1"
}
}
...
...
This diff is collapsed.
Click to expand it.
server/app/database/controller/delete.py
+
22
−
0
View file @
8b50cff4
"""
This file contains functionality to delete data to the database.
"""
import
app.database.controller
as
dbc
import
app.database.controller
as
dbc
from
app.core
import
db
from
app.core
import
db
from
app.database.models
import
Blacklist
,
City
,
Competition
,
Role
,
Slide
,
User
from
app.database.models
import
Blacklist
,
City
,
Competition
,
Role
,
Slide
,
User
def
default
(
item
):
def
default
(
item
):
"""
Deletes item and commits.
"""
db
.
session
.
delete
(
item
)
db
.
session
.
delete
(
item
)
db
.
session
.
commit
()
db
.
session
.
commit
()
def
component
(
item_component
):
def
component
(
item_component
):
"""
Deletes component.
"""
default
(
item_component
)
default
(
item_component
)
def
_slide
(
item_slide
):
def
_slide
(
item_slide
):
"""
Internal delete for slide.
"""
for
item_question
in
item_slide
.
questions
:
for
item_question
in
item_slide
.
questions
:
question
(
item_question
)
question
(
item_question
)
...
@@ -23,6 +33,8 @@ def _slide(item_slide):
...
@@ -23,6 +33,8 @@ def _slide(item_slide):
def
slide
(
item_slide
):
def
slide
(
item_slide
):
"""
Deletes slide and updates order of other slides if neccesary.
"""
competition_id
=
item_slide
.
competition_id
competition_id
=
item_slide
.
competition_id
slide_order
=
item_slide
.
order
slide_order
=
item_slide
.
order
...
@@ -38,12 +50,16 @@ def slide(item_slide):
...
@@ -38,12 +50,16 @@ def slide(item_slide):
def
team
(
item_team
):
def
team
(
item_team
):
"""
Deletes team and its question answers.
"""
for
item_question_answer
in
item_team
.
question_answers
:
for
item_question_answer
in
item_team
.
question_answers
:
question_answers
(
item_question_answer
)
question_answers
(
item_question_answer
)
default
(
item_team
)
default
(
item_team
)
def
question
(
item_question
):
def
question
(
item_question
):
"""
Deletes question and its alternatives and answers.
"""
for
item_question_answer
in
item_question
.
question_answers
:
for
item_question_answer
in
item_question
.
question_answers
:
question_answers
(
item_question_answer
)
question_answers
(
item_question_answer
)
for
item_alternative
in
item_question
.
alternatives
:
for
item_alternative
in
item_question
.
alternatives
:
...
@@ -52,14 +68,20 @@ def question(item_question):
...
@@ -52,14 +68,20 @@ def question(item_question):
def
alternatives
(
item_alternatives
):
def
alternatives
(
item_alternatives
):
"""
Deletes question alternative.
"""
default
(
item_alternatives
)
default
(
item_alternatives
)
def
question_answers
(
item_question_answers
):
def
question_answers
(
item_question_answers
):
"""
Deletes question answer.
"""
default
(
item_question_answers
)
default
(
item_question_answers
)
def
competition
(
item_competition
):
def
competition
(
item_competition
):
"""
Deletes competition and its slides and teams.
"""
for
item_slide
in
item_competition
.
slides
:
for
item_slide
in
item_competition
.
slides
:
_slide
(
item_slide
)
_slide
(
item_slide
)
for
item_team
in
item_competition
.
teams
:
for
item_team
in
item_competition
.
teams
:
...
...
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