-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create training app, models and fixtures
- Loading branch information
Showing
15 changed files
with
278 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.contrib import admin | ||
from training import models | ||
|
||
|
||
class ContentBlockInline(admin.StackedInline): | ||
model = models.ContentBlock | ||
extra = 1 | ||
|
||
|
||
class QuizChoiceInline(admin.TabularInline): | ||
model = models.QuizChoice | ||
extra = 1 | ||
|
||
|
||
class QuizInline(admin.StackedInline): | ||
model = models.Quiz | ||
inlines = [QuizChoiceInline, ] | ||
extra = 1 | ||
|
||
|
||
@admin.register(models.Quiz) | ||
class QuizAdmin(admin.ModelAdmin): | ||
list_display = ('training', 'question', 'order') | ||
inlines = [QuizChoiceInline, ] | ||
|
||
|
||
@admin.register(models.OnPlatformTraining) | ||
class OnPlatformTrainingAdmin(admin.ModelAdmin): | ||
list_display = ('training', 'version') | ||
inlines = [ContentBlockInline, QuizInline] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class TrainingConfig(AppConfig): | ||
name = 'training' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
[ | ||
{ | ||
"model": "training.onplatformtraining", | ||
"pk": 1, | ||
"fields": { | ||
"training": 2, | ||
"version": 1.0 | ||
} | ||
}, | ||
{ | ||
"model": "training.contentblock", | ||
"pk": 1, | ||
"fields": { | ||
"training": 1, | ||
"body": "Content Body 1", | ||
"order": 1 | ||
} | ||
}, | ||
{ | ||
"model": "training.contentblock", | ||
"pk": 2, | ||
"fields": { | ||
"training": 1, | ||
"body": "Content Body 2", | ||
"order": 3 | ||
} | ||
}, | ||
{ | ||
"model": "training.quiz", | ||
"pk": 1, | ||
"fields": { | ||
"training": 1, | ||
"question": "Which of this is not a country in America?", | ||
"order": 2 | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 1, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Canada", | ||
"is_correct": false | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 2, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Spain", | ||
"is_correct": true | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 3, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Cuba", | ||
"is_correct": false | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 4, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Mexico", | ||
"is_correct": false | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Generated by Django 4.1.5 on 2023-02-20 18:16 | ||
|
||
import ckeditor_uploader.fields | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('user', '0052_alter_trainingtype_required_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='OnPlatformTraining', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('version', models.FloatField(default=1.0, unique=True)), | ||
('training', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='op_trainings', to='user.trainingtype')), | ||
], | ||
options={ | ||
'default_permissions': ('change',), | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Quiz', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('question', ckeditor_uploader.fields.RichTextUploadingField()), | ||
('order', models.PositiveIntegerField()), | ||
('training', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='quizzes', to='training.onplatformtraining')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='QuizChoice', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('body', models.TextField()), | ||
('is_correct', models.BooleanField(default=False, verbose_name='Correct Choice?')), | ||
('quiz', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='choices', to='training.quiz')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='ContentBlock', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('body', ckeditor_uploader.fields.RichTextUploadingField()), | ||
('order', models.PositiveIntegerField()), | ||
('training', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='contents', to='training.onplatformtraining')), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.db import models | ||
|
||
from ckeditor_uploader.fields import RichTextUploadingField | ||
|
||
|
||
class OnPlatformTraining(models.Model): | ||
training = models.ForeignKey('user.TrainingType', | ||
on_delete=models.CASCADE, related_name='op_trainings') | ||
version = models.FloatField(default=1.0, unique=True) | ||
|
||
class Meta: | ||
default_permissions = ('change',) | ||
|
||
|
||
class Quiz(models.Model): | ||
question = RichTextUploadingField() | ||
training = models.ForeignKey('training.OnPlatformTraining', | ||
on_delete=models.CASCADE, related_name='quizzes') | ||
order = models.PositiveIntegerField() | ||
|
||
|
||
class ContentBlock(models.Model): | ||
training = models.ForeignKey('training.OnPlatformTraining', | ||
on_delete=models.CASCADE, related_name='contents') | ||
body = RichTextUploadingField() | ||
order = models.PositiveIntegerField() | ||
|
||
|
||
class QuizChoice(models.Model): | ||
quiz = models.ForeignKey('training.Quiz', | ||
on_delete=models.CASCADE, related_name='choices') | ||
body = models.TextField() | ||
is_correct = models.BooleanField('Correct Choice?', default=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Console | ||
- Add a create training type button * | ||
- View all Training with button beside asking to make it OP * | ||
- Button on-top asking to create a training type | ||
- Add a button to download sample json/ paste the sample json on the page * | ||
- Modify the settings training page to display the latest versions | ||
- Write test cases for them all | ||
- Write a function that puts all validity at 30 days and sends a mail asking them to retake the training for major version change * | ||
- Change the trainingType required_field to Platform from serializer | ||
|
||
|
||
New Branch | ||
- Create the Training App, as well as their models, admins, fixtures, migrations, apps, | ||
- Another PR for the views and viewing it from settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# write your views here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
physionet-django/user/migrations/0052_alter_trainingtype_required_field.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 4.1.5 on 2023-02-18 02:12 | ||
|
||
from django.db import migrations, models | ||
import user.enums | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('user', '0051_credentialapplication_auto_rejection_reason'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='trainingtype', | ||
name='required_field', | ||
field=models.PositiveSmallIntegerField( | ||
choices=[(0, 'DOCUMENT'), (1, 'URL'), (2, 'PLATFORM')], | ||
default=user.enums.RequiredField['DOCUMENT']), | ||
), | ||
] |