Commit a8e34ddc authored by Benoit Alessandroni's avatar Benoit Alessandroni

Fixing some models

parent 497638c6
......@@ -12,12 +12,11 @@
"description":"Pellentesque urna neque, posuere ac vulputate et, rhoncus ut nisi. Etiam at ligula eget orci viverra fermentum id pellentesque ante.",
"iframe_link":"",
"preview_image":"",
"review": 1,
"target":"public",
"type":1,
"sharing":"public",
"format":[
2
],
"format": 2,
"submitter":1,
"fields":[
7
......@@ -43,10 +42,9 @@
"preview_image":"",
"target":"public",
"type":1,
"review": 2,
"sharing":"public",
"format":[
3
],
"format": 3,
"submitter":1,
"fields":[
7
......@@ -73,9 +71,8 @@
"target":"public",
"type":2,
"sharing":"public",
"format":[
3
],
"format":3,
"review": 3,
"submitter":2,
"fields":[
7,
......@@ -104,9 +101,8 @@
"target":"public",
"type":2,
"sharing":"public",
"format":[
4
],
"format":4,
"review": 4,
"submitter":2,
"fields":[
7,
......@@ -135,11 +131,8 @@
"target":"public",
"type":1,
"sharing":"public",
"format":[
2,
3,
4
],
"format":4,
"review": 5,
"submitter":2,
"fields":[
1,
......@@ -171,9 +164,8 @@
"target":"public",
"type":2,
"sharing":"public",
"format":[
5
],
"format":5,
"review": 6,
"submitter":2,
"fields":[
1,
......@@ -202,10 +194,8 @@
"target":"mentor",
"type":1,
"sharing":"private",
"format":[
1,
5
],
"format":5,
"review": 7,
"submitter":1,
"fields":[
2,
......@@ -234,11 +224,8 @@
"target":"entrepreneur",
"type":2,
"sharing":"public",
"format":[
1,
2,
3
],
"format":2,
"review": 8,
"submitter":2,
"fields":[
5,
......@@ -269,10 +256,8 @@
"target":"mentor",
"type":1,
"sharing":"private",
"format":[
4,
5
],
"format":5,
"review": 9,
"submitter":2,
"fields":[
2,
......@@ -301,10 +286,8 @@
"target":"mentor",
"type":1,
"sharing":"private",
"format":[
1,
6
],
"format":6,
"review": 10,
"submitter":1,
"fields":[
8,
......@@ -333,10 +316,8 @@
"target":"mentor",
"type":1,
"sharing":"private",
"format":[
4,
2
],
"format":6,
"review": 11,
"submitter":1,
"fields":[
1,
......
[
{
"model": "coopstarter_data.review",
"pk": 1,
"fields": {
"reviewer": 2,
"comment": "It is ok!",
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 2,
"fields": {
"reviewer": 2,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 3,
"fields": {
"reviewer": 1,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 4,
"fields": {
"reviewer": 1,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 5,
"fields": {
"reviewer": 1,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 6,
"fields": {
"reviewer": 1,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 7,
"fields": {
"reviewer": 2,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 8,
"fields": {
"reviewer": 1,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 9,
"fields": {
"reviewer": 1,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 10,
"fields": {
"reviewer": 2,
"status": "validated"
}
},
{
"model": "coopstarter_data.review",
"pk": 11,
"fields": {
"reviewer": 2,
"status": "validated"
}
}
]
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-10-02 18:40
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('coopstarter_data', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='request',
name='organisation',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests', to='coopstarter_data.Organisation'),
),
migrations.RemoveField(
model_name='resource',
name='format',
),
migrations.AddField(
model_name='resource',
name='format',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='resources', to='coopstarter_data.Format'),
),
migrations.AlterField(
model_name='resource',
name='language',
field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='resources', to='coopstarter_data.Language', verbose_name='Language'),
),
]
......@@ -131,9 +131,9 @@ class Resource (Model):
# Mandatory Fields
name = models.CharField(max_length=32, verbose_name="Title")
format = models.ManyToManyField(Format, blank=True, related_name='resources')
format = models.ForeignKey(Format, null=True, related_name='resources')
publication_year = models.IntegerField(verbose_name="Publication Year")
language = models.ForeignKey(Language, blank=True, verbose_name="Language")
language = models.ForeignKey(Language, blank=True, verbose_name="Language", related_name='resources')
fields = models.ManyToManyField(Field, blank=True, related_name='resources')
country = CountryField(verbose_name="Country of publication", blank=True)
uri = models.CharField(max_length=4086, verbose_name="Location/weblink")
......@@ -190,7 +190,7 @@ class Request (Model):
fields = models.ManyToManyField(Field, blank=True)
country = CountryField(verbose_name="Country of publication", blank=True)
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE, related_name="requests")
skills = models.TextField(verbose_name="Learning outcomes/skills")
target = models.CharField(max_length=32, choices=(('mentor', 'Mentor'), ('entrepreneur', 'Entrepreneur'), ('public', 'Public')), verbose_name="Target audience", blank=True, null=True)
......@@ -218,9 +218,10 @@ class Request (Model):
@receiver(post_save, sender=Resource)
def create_review(sender, instance, created, **kwargs):
if created:
reviewInstance = Review.objects.create(resource=instance, status="pending")
instance.review = reviewInstance
instance.save()
if not instance.review:
reviewInstance = Review.objects.create(resource=instance, status="pending")
instance.review = reviewInstance
instance.save()
if not created:
#TODO: If we are updating a resource which requires improvement,
#we can send a notification to the current reviewer for further review
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment