Pamela Fox
commited on
Commit
·
669c0b8
1
Parent(s):
fb79ec6
Ruff updates
Browse files- .pre-commit-config.yaml +3 -3
- infra/main.bicep +9 -0
- quizsite/production.py +1 -0
- quizsite/settings.py +1 -2
- quizzes/admin.py +2 -1
- quizzes/migrations/0001_initial.py +2 -5
- quizzes/migrations/0002_remove_question_answer_status_and_more.py +3 -8
- quizzes/models.py +1 -1
- quizzes/tests.py +1 -1
- quizzes/views.py +2 -2
.pre-commit-config.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
repos:
|
2 |
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
-
rev:
|
4 |
hooks:
|
5 |
- id: check-yaml
|
6 |
- id: end-of-file-fixer
|
7 |
- id: trailing-whitespace
|
8 |
- repo: https://github.com/psf/black
|
9 |
-
rev:
|
10 |
hooks:
|
11 |
- id: black
|
12 |
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
13 |
-
rev: v0.0.
|
14 |
hooks:
|
15 |
- id: ruff
|
|
|
1 |
repos:
|
2 |
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
+
rev: v4.4.0
|
4 |
hooks:
|
5 |
- id: check-yaml
|
6 |
- id: end-of-file-fixer
|
7 |
- id: trailing-whitespace
|
8 |
- repo: https://github.com/psf/black
|
9 |
+
rev: 23.1.0
|
10 |
hooks:
|
11 |
- id: black
|
12 |
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
13 |
+
rev: v0.0.258
|
14 |
hooks:
|
15 |
- id: ruff
|
infra/main.bicep
CHANGED
@@ -100,6 +100,15 @@ module appServicePlan 'core/host/appserviceplan.bicep' = {
|
|
100 |
}
|
101 |
}
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
// Store secrets in a keyvault
|
104 |
module keyVault './core/security/keyvault.bicep' = {
|
105 |
name: 'keyvault'
|
|
|
100 |
}
|
101 |
}
|
102 |
|
103 |
+
module webKeyVaultAccess 'core/security/keyvault-access.bicep' = {
|
104 |
+
name: 'web-keyvault-access'
|
105 |
+
scope: resourceGroup
|
106 |
+
params: {
|
107 |
+
keyVaultName: keyVault.outputs.name
|
108 |
+
principalId: web.outputs.identityPrincipalId
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
// Store secrets in a keyvault
|
113 |
module keyVault './core/security/keyvault.bicep' = {
|
114 |
name: 'keyvault'
|
quizsite/production.py
CHANGED
@@ -19,5 +19,6 @@ DATABASES = {
|
|
19 |
"HOST": hostname + ".postgres.database.azure.com",
|
20 |
"USER": os.environ["DBUSER"],
|
21 |
"PASSWORD": os.environ["DBPASS"],
|
|
|
22 |
}
|
23 |
}
|
|
|
19 |
"HOST": hostname + ".postgres.database.azure.com",
|
20 |
"USER": os.environ["DBUSER"],
|
21 |
"PASSWORD": os.environ["DBPASS"],
|
22 |
+
"OPTIONS": {"sslmode": "require"},
|
23 |
}
|
24 |
}
|
quizsite/settings.py
CHANGED
@@ -10,9 +10,8 @@ For the full list of settings and their values, see
|
|
10 |
https://docs.djangoproject.com/en/4.1/ref/settings/
|
11 |
"""
|
12 |
|
13 |
-
from pathlib import Path
|
14 |
import os
|
15 |
-
|
16 |
|
17 |
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
18 |
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
10 |
https://docs.djangoproject.com/en/4.1/ref/settings/
|
11 |
"""
|
12 |
|
|
|
13 |
import os
|
14 |
+
from pathlib import Path
|
15 |
|
16 |
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
17 |
BASE_DIR = Path(__file__).resolve().parent.parent
|
quizzes/admin.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from django.contrib import admin
|
2 |
-
|
|
|
3 |
|
4 |
admin.site.register(Quiz)
|
5 |
|
|
|
1 |
from django.contrib import admin
|
2 |
+
|
3 |
+
from .models import FreeTextAnswer, MultipleChoiceAnswer, Question, Quiz
|
4 |
|
5 |
admin.site.register(Quiz)
|
6 |
|
quizzes/migrations/0001_initial.py
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
# Generated by Django 4.1.1 on 2022-09-14 18:17
|
2 |
|
3 |
import django.contrib.postgres.fields
|
4 |
-
from django.db import migrations, models
|
5 |
import django.db.models.deletion
|
|
|
6 |
|
7 |
|
8 |
class Migration(migrations.Migration):
|
9 |
-
|
10 |
initial = True
|
11 |
|
12 |
dependencies = []
|
@@ -46,9 +45,7 @@ class Migration(migrations.Migration):
|
|
46 |
),
|
47 |
(
|
48 |
"quiz",
|
49 |
-
models.ForeignKey(
|
50 |
-
on_delete=django.db.models.deletion.CASCADE, to="quizzes.quiz"
|
51 |
-
),
|
52 |
),
|
53 |
],
|
54 |
),
|
|
|
1 |
# Generated by Django 4.1.1 on 2022-09-14 18:17
|
2 |
|
3 |
import django.contrib.postgres.fields
|
|
|
4 |
import django.db.models.deletion
|
5 |
+
from django.db import migrations, models
|
6 |
|
7 |
|
8 |
class Migration(migrations.Migration):
|
|
|
9 |
initial = True
|
10 |
|
11 |
dependencies = []
|
|
|
45 |
),
|
46 |
(
|
47 |
"quiz",
|
48 |
+
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="quizzes.quiz"),
|
|
|
|
|
49 |
),
|
50 |
],
|
51 |
),
|
quizzes/migrations/0002_remove_question_answer_status_and_more.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
# Generated by Django 4.1.1 on 2022-09-15 00:57
|
2 |
|
3 |
-
from django.db import migrations, models
|
4 |
import django.db.models.deletion
|
|
|
5 |
|
6 |
|
7 |
class Migration(migrations.Migration):
|
8 |
-
|
9 |
dependencies = [
|
10 |
("quizzes", "0001_initial"),
|
11 |
]
|
@@ -18,15 +17,11 @@ class Migration(migrations.Migration):
|
|
18 |
migrations.AlterField(
|
19 |
model_name="freetextanswer",
|
20 |
name="question",
|
21 |
-
field=models.OneToOneField(
|
22 |
-
on_delete=django.db.models.deletion.CASCADE, to="quizzes.question"
|
23 |
-
),
|
24 |
),
|
25 |
migrations.AlterField(
|
26 |
model_name="multiplechoiceanswer",
|
27 |
name="question",
|
28 |
-
field=models.OneToOneField(
|
29 |
-
on_delete=django.db.models.deletion.CASCADE, to="quizzes.question"
|
30 |
-
),
|
31 |
),
|
32 |
]
|
|
|
1 |
# Generated by Django 4.1.1 on 2022-09-15 00:57
|
2 |
|
|
|
3 |
import django.db.models.deletion
|
4 |
+
from django.db import migrations, models
|
5 |
|
6 |
|
7 |
class Migration(migrations.Migration):
|
|
|
8 |
dependencies = [
|
9 |
("quizzes", "0001_initial"),
|
10 |
]
|
|
|
17 |
migrations.AlterField(
|
18 |
model_name="freetextanswer",
|
19 |
name="question",
|
20 |
+
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="quizzes.question"),
|
|
|
|
|
21 |
),
|
22 |
migrations.AlterField(
|
23 |
model_name="multiplechoiceanswer",
|
24 |
name="question",
|
25 |
+
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="quizzes.question"),
|
|
|
|
|
26 |
),
|
27 |
]
|
quizzes/models.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
from django.db import models
|
2 |
from django.contrib.postgres import fields
|
|
|
3 |
|
4 |
|
5 |
class Quiz(models.Model):
|
|
|
|
|
1 |
from django.contrib.postgres import fields
|
2 |
+
from django.db import models
|
3 |
|
4 |
|
5 |
class Quiz(models.Model):
|
quizzes/tests.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from django.test import TestCase
|
2 |
from django.urls import reverse
|
3 |
|
4 |
-
from .models import
|
5 |
|
6 |
|
7 |
def create_quiz():
|
|
|
1 |
from django.test import TestCase
|
2 |
from django.urls import reverse
|
3 |
|
4 |
+
from .models import FreeTextAnswer, MultipleChoiceAnswer, Question, Quiz
|
5 |
|
6 |
|
7 |
def create_quiz():
|
quizzes/views.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
from django.shortcuts import get_object_or_404,
|
2 |
from django.urls import reverse
|
3 |
from django.views import generic
|
4 |
|
5 |
-
from .models import
|
6 |
|
7 |
|
8 |
class IndexView(generic.ListView):
|
|
|
1 |
+
from django.shortcuts import get_object_or_404, redirect, render
|
2 |
from django.urls import reverse
|
3 |
from django.views import generic
|
4 |
|
5 |
+
from .models import Question, Quiz
|
6 |
|
7 |
|
8 |
class IndexView(generic.ListView):
|