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
d7408297
Commit
d7408297
authored
4 years ago
by
Josef Olsson
Browse files
Options
Downloads
Patches
Plain Diff
Edit name constraint of competition
parent
4ea926bb
No related branches found
No related tags found
1 merge request
!158
Fix copying question alternatives and its test code
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/src/pages/admin/competitions/AddCompetition.tsx
+4
-1
4 additions, 1 deletion
client/src/pages/admin/competitions/AddCompetition.tsx
server/app/database/models.py
+4
-3
4 additions, 3 deletions
server/app/database/models.py
server/populate.py
+15
-15
15 additions, 15 deletions
server/populate.py
with
23 additions
and
19 deletions
client/src/pages/admin/competitions/AddCompetition.tsx
+
4
−
1
View file @
d7408297
...
@@ -75,7 +75,10 @@ const AddCompetition: React.FC = (props: any) => {
...
@@ -75,7 +75,10 @@ const AddCompetition: React.FC = (props: any) => {
.
catch
(({
response
})
=>
{
.
catch
(({
response
})
=>
{
console
.
warn
(
response
.
data
)
console
.
warn
(
response
.
data
)
if
(
response
?.
status
===
409
)
if
(
response
?.
status
===
409
)
actions
.
setFieldError
(
'
error
'
,
'
En tävling med det namnet finns redan, välj ett nytt namn och försök igen
'
)
actions
.
setFieldError
(
'
error
'
,
'
Denna tävling finns redan, välj ett nytt namn, region eller år och försök igen
'
)
else
if
(
response
.
data
&&
response
.
data
.
message
)
else
if
(
response
.
data
&&
response
.
data
.
message
)
actions
.
setFieldError
(
'
error
'
,
response
.
data
&&
response
.
data
.
message
)
actions
.
setFieldError
(
'
error
'
,
response
.
data
&&
response
.
data
.
message
)
else
actions
.
setFieldError
(
'
error
'
,
'
Någonting gick fel, försök igen
'
)
else
actions
.
setFieldError
(
'
error
'
,
'
Någonting gick fel, försök igen
'
)
...
...
This diff is collapsed.
Click to expand it.
server/app/database/models.py
+
4
−
3
View file @
d7408297
...
@@ -5,8 +5,7 @@ each other.
...
@@ -5,8 +5,7 @@ each other.
"""
"""
from
app.core
import
bcrypt
,
db
from
app.core
import
bcrypt
,
db
from
app.database.types
import
(
IMAGE_COMPONENT_ID
,
QUESTION_COMPONENT_ID
,
from
app.database.types
import
IMAGE_COMPONENT_ID
,
QUESTION_COMPONENT_ID
,
TEXT_COMPONENT_ID
TEXT_COMPONENT_ID
)
from
sqlalchemy.ext.hybrid
import
hybrid_method
,
hybrid_property
from
sqlalchemy.ext.hybrid
import
hybrid_method
,
hybrid_property
from
sqlalchemy.orm
import
backref
from
sqlalchemy.orm
import
backref
...
@@ -145,8 +144,9 @@ class Competition(db.Model):
...
@@ -145,8 +144,9 @@ class Competition(db.Model):
Depend on table: Media, City.
Depend on table: Media, City.
"""
"""
__table_args__
=
(
db
.
UniqueConstraint
(
"
name
"
,
"
year
"
,
"
city_id
"
),)
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
STRING_SIZE
),
unique
=
Tru
e
)
name
=
db
.
Column
(
db
.
String
(
STRING_SIZE
),
nullable
=
Fals
e
)
year
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
2020
)
year
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
2020
)
font
=
db
.
Column
(
db
.
String
(
STRING_SIZE
),
nullable
=
False
)
font
=
db
.
Column
(
db
.
String
(
STRING_SIZE
),
nullable
=
False
)
city_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
"
city.id
"
),
nullable
=
False
)
city_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
"
city.id
"
),
nullable
=
False
)
...
@@ -242,6 +242,7 @@ class QuestionAlternative(db.Model):
...
@@ -242,6 +242,7 @@ class QuestionAlternative(db.Model):
Depend on table: Question.
Depend on table: Question.
"""
"""
__table_args__
=
(
__table_args__
=
(
db
.
UniqueConstraint
(
"
question_id
"
,
"
alternative_order
"
),
db
.
UniqueConstraint
(
"
question_id
"
,
"
alternative_order
"
),
db
.
UniqueConstraint
(
"
question_id
"
,
"
correct_order
"
),
db
.
UniqueConstraint
(
"
question_id
"
,
"
correct_order
"
),
...
...
This diff is collapsed.
Click to expand it.
server/populate.py
+
15
−
15
View file @
d7408297
...
@@ -56,21 +56,21 @@ def create_default_items():
...
@@ -56,21 +56,21 @@ def create_default_items():
dbc
.
add
.
user
(
"
admin@test.se
"
,
"
password
"
,
admin_id
,
city_id
,
"
Admina Denfina
"
)
dbc
.
add
.
user
(
"
admin@test.se
"
,
"
password
"
,
admin_id
,
city_id
,
"
Admina Denfina
"
)
dbc
.
add
.
user
(
"
test@test.se
"
,
"
password
"
,
editor_id
,
city_id
,
"
Test Osteron
"
)
dbc
.
add
.
user
(
"
test@test.se
"
,
"
password
"
,
editor_id
,
city_id
,
"
Test Osteron
"
)
#
dbc.add.user("sven@test.se", "password", editor_id, 1, "Sven Mattson")
dbc
.
add
.
user
(
"
sven@test.se
"
,
"
password
"
,
editor_id
,
1
,
"
Sven Mattson
"
)
#
dbc.add.user("erika@test.se", "password", editor_id, 2, "Erika Malmberg")
dbc
.
add
.
user
(
"
erika@test.se
"
,
"
password
"
,
editor_id
,
2
,
"
Erika Malmberg
"
)
#
dbc.add.user("anette@test.se", "password", editor_id, 3, "Anette Frisk")
dbc
.
add
.
user
(
"
anette@test.se
"
,
"
password
"
,
editor_id
,
3
,
"
Anette Frisk
"
)
#
dbc.add.user("emil@test.se", "password", editor_id, 4, "Emil Svensson")
dbc
.
add
.
user
(
"
emil@test.se
"
,
"
password
"
,
editor_id
,
4
,
"
Emil Svensson
"
)
#
dbc.add.user("david@test.se", "password", editor_id, 5, "David Ek")
dbc
.
add
.
user
(
"
david@test.se
"
,
"
password
"
,
editor_id
,
5
,
"
David Ek
"
)
#
dbc.add.competition(f"Regionfinal", 2012, 1)
dbc
.
add
.
competition
(
f
"
Regionfinal
"
,
2012
,
1
)
#
dbc.add.competition(f"Regionfinal", 2012, 2)
dbc
.
add
.
competition
(
f
"
Regionfinal
"
,
2012
,
2
)
#
dbc.add.competition(f"Regionfinal", 2012, 3)
dbc
.
add
.
competition
(
f
"
Regionfinal
"
,
2012
,
3
)
#
dbc.add.competition(f"Regionfinal", 2012, 4)
dbc
.
add
.
competition
(
f
"
Regionfinal
"
,
2012
,
4
)
#
dbc.add.competition(f"Regionfinal", 2012, 5)
dbc
.
add
.
competition
(
f
"
Regionfinal
"
,
2012
,
5
)
#
dbc.add.competition(f"Rikssemifinal", 2012, 6)
dbc
.
add
.
competition
(
f
"
Rikssemifinal
"
,
2012
,
6
)
#
dbc.add.competition(f"Rikssemifinal", 2012, 7)
dbc
.
add
.
competition
(
f
"
Rikssemifinal
"
,
2012
,
7
)
#
dbc.add.competition(f"Rikssemifinal", 2012, 8)
dbc
.
add
.
competition
(
f
"
Rikssemifinal
"
,
2012
,
8
)
#
dbc.add.competition(f"Riksfinal", 2012, 9)
dbc
.
add
.
competition
(
f
"
Riksfinal
"
,
2012
,
9
)
question_types_items
=
dbc
.
get
.
all
(
QuestionType
)
question_types_items
=
dbc
.
get
.
all
(
QuestionType
)
...
...
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