-
Notifications
You must be signed in to change notification settings - Fork 0
1371 certification type #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
c77e25c
d09aeb5
0092fff
7de9b96
a35044f
d5427d7
745b191
547869c
79e0987
bfab4ac
f4b45d3
0e1a285
7f837e5
c1a2cb5
613dbe7
a1c5b72
3fb6b64
af6b582
ec6763c
1f76a37
935b99a
45ca0e3
5c798d9
22db5b5
2adf94e
5aeacd6
85bd0b4
cf89c41
b2895c7
13f8c1a
75fe979
6560b4c
4398bef
f2254ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Generated by Django 2.2.18 on 2021-12-03 00:56 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| def add_certification_type_as_existing_value(apps, schema_editor): | ||
| CertificateType = apps.get_model('certification', 'CertificateType') | ||
| CertificateType.objects.create( | ||
| name='attendance and completion', | ||
| wording='Has attended and completed the course:', | ||
| order=0 | ||
| ) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('certification', '0006_auto_20210730_0615'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='CertificateType', | ||
| fields=[ | ||
| ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('name', models.CharField(help_text='Certificate type.', max_length=200, unique=True)), | ||
| ('description', models.TextField(blank=True, help_text='Certificate type description - 1000 characters limit.', max_length=1000, null=True)), | ||
| ('wording', models.CharField(help_text='Wording that will be placed on certificate. e.g. "Has attended and completed".', max_length=500)), | ||
| ('order', models.IntegerField(blank=True, null=True, unique=True)), | ||
| ], | ||
| ), | ||
|
|
||
| migrations.RunPython(add_certification_type_as_existing_value, reverse_code=migrations.RunPython.noop), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Generated by Django 2.2.18 on 2021-11-26 04:51 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('certification', '0006_auto_20210730_0615'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='courseconvener', | ||
| name='is_active', | ||
| field=models.BooleanField(default=True, help_text='Inactive Convener will not be available in your organisation list.'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Generated by Django 2.2.18 on 2021-12-10 02:23 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
| def create_existing_project_certificate_type(apps, schema_editor): | ||
| CertificateType = apps.get_model('certification', 'CertificateType') | ||
| ProjectCertificateType = apps.get_model('certification', 'ProjectCertificateType') | ||
| Project = apps.get_model('base', 'Project') | ||
| certificate_type = CertificateType.objects.filter( | ||
| name='attendance and completion').first() | ||
| projects = Project.objects.all() | ||
|
|
||
| for project in projects: | ||
| ProjectCertificateType.objects.create( | ||
| project=project, | ||
| certificate_type=certificate_type | ||
| ) | ||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('base', '0006_auto_20210308_0244'), | ||
| ('certification', '0007_certificatetype'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='ProjectCertificateType', | ||
| fields=[ | ||
| ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('certificate_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='certification.CertificateType')), | ||
| ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='base.Project')), | ||
| ], | ||
| ), | ||
|
|
||
| migrations.RunPython(create_existing_project_certificate_type, reverse_code=migrations.RunPython.noop), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Generated by Django 2.2.18 on 2021-12-10 08:31 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
| def set_existing_certificate_type_value(apps, shcema_editor): | ||
| CertificateType = apps.get_model('certification', 'CertificateType') | ||
| Course = apps.get_model('certification', 'Course') | ||
| certificate_type = CertificateType.objects.filter( | ||
| name='attendance and completion').first() | ||
| courses = Course.objects.all() | ||
|
|
||
| for course in courses: | ||
| course.certificate_type = certificate_type | ||
| course.save(update_fields=['certificate_type']) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('certification', '0008_projectcertificatetype'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='course', | ||
| name='certificate_type', | ||
| field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='certification.CertificateType'), | ||
| ), | ||
|
|
||
| migrations.RunPython(set_existing_certificate_type_value, reverse_code=migrations.RunPython.noop), | ||
|
|
||
| migrations.AlterField( | ||
| model_name='course', | ||
| name='certificate_type', | ||
| field=models.ForeignKey(null=False, on_delete=django.db.models.deletion.PROTECT, | ||
| to='certification.CertificateType'), | ||
| preserve_default=False, | ||
| ), | ||
|
|
||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Generated by Django 2.2.18 on 2022-02-12 02:17 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('certification', '0007_courseconvener_is_active'), | ||
| ('certification', '0009_course_certificate_type'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||||||||||||||||||||||||||||
| """Certificate type model for certification app""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| from django.db import models | ||||||||||||||||||||||||||||||||
| from django.utils.translation import ugettext_lazy as _ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| from base.models.project import Project | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| class CertificateType(models.Model): | ||||||||||||||||||||||||||||||||
| name = models.CharField( | ||||||||||||||||||||||||||||||||
| help_text=_('Certificate type.'), | ||||||||||||||||||||||||||||||||
| max_length=200, | ||||||||||||||||||||||||||||||||
| null=False, | ||||||||||||||||||||||||||||||||
| blank=False, | ||||||||||||||||||||||||||||||||
| unique=True, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| description = models.TextField( | ||||||||||||||||||||||||||||||||
| help_text=_('Certificate type description - 1000 characters limit.'), | ||||||||||||||||||||||||||||||||
| max_length=1000, | ||||||||||||||||||||||||||||||||
| null=True, | ||||||||||||||||||||||||||||||||
| blank=True, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+18
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| wording = models.CharField( | ||||||||||||||||||||||||||||||||
| help_text=_( | ||||||||||||||||||||||||||||||||
| 'Wording that will be placed on certificate. ' | ||||||||||||||||||||||||||||||||
| 'e.g. "Has attended and completed".' | ||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||
| max_length=500, | ||||||||||||||||||||||||||||||||
| null=False, | ||||||||||||||||||||||||||||||||
| blank=False | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Likewise, redundant default arguments can be removed. Likewise, redundant default arguments can be removed. |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| order = models.IntegerField( | ||||||||||||||||||||||||||||||||
| blank=True, | ||||||||||||||||||||||||||||||||
| null=True, | ||||||||||||||||||||||||||||||||
| unique=True | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| def __str__(self): | ||||||||||||||||||||||||||||||||
| return self.name | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| class ProjectCertificateType(models.Model): | ||||||||||||||||||||||||||||||||
| """A model to store a certificate type linked to a project""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| project = models.ForeignKey( | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Django automatically creates a |
||||||||||||||||||||||||||||||||
| Project, | ||||||||||||||||||||||||||||||||
| on_delete=models.CASCADE | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
| certificate_type = models.ForeignKey( | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, with an explicit |
||||||||||||||||||||||||||||||||
| CertificateType, | ||||||||||||||||||||||||||||||||
| on_delete=models.CASCADE | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |||||||||||
| from .course_type import CourseType | ||||||||||||
| from certification.utilities import check_slug | ||||||||||||
| from .training_center import TrainingCenter | ||||||||||||
| from certification.models.certificate_type import CertificateType | ||||||||||||
|
|
||||||||||||
| logger = logging.getLogger(__name__) | ||||||||||||
|
|
||||||||||||
|
|
@@ -86,6 +87,8 @@ class Course(models.Model): | |||||||||||
| on_delete=models.CASCADE) | ||||||||||||
| certifying_organisation = models.ForeignKey(CertifyingOrganisation, | ||||||||||||
| on_delete=models.CASCADE) | ||||||||||||
| certificate_type = models.ForeignKey( | ||||||||||||
| CertificateType, on_delete=models.PROTECT, null=True) | ||||||||||||
|
Comment on lines
+90
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Django automatically creates a Expect unwanted behavior if |
||||||||||||
| author = models.ForeignKey(User, on_delete=models.CASCADE) | ||||||||||||
| objects = models.Manager() | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Falseis the default value Django uses fornull, sonull=Falsecan be removed. Explained here.Similarly, redundant default arguments can be removed.