diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..0bd7587 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2016-09-06 17:50 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Action', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100, verbose_name='Name')), + ('created_date', models.DateField(auto_now_add=True, verbose_name='Created Date')), + ], + options={ + 'verbose_name': 'Action', + 'verbose_name_plural': 'Actions', + }, + ), + migrations.CreateModel( + name='Action_Resource', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('action', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action', verbose_name='Action_Applied')), + ], + options={ + 'verbose_name': 'Action_Resource', + 'verbose_name_plural': 'Action_Resources', + }, + ), + migrations.CreateModel( + name='Notification', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('message', models.TextField(verbose_name='message')), + ('read', models.BooleanField(default=False, verbose_name='Read')), + ('action_resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action_Resource', verbose_name='Action_Resource')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Actor')), + ], + options={ + 'verbose_name': 'Action_Resource', + 'verbose_name_plural': 'Action_Resources', + }, + ), + migrations.CreateModel( + name='Resource', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100, verbose_name='Name')), + ('created_date', models.DateField(auto_now_add=True, verbose_name='Created Date')), + ], + options={ + 'verbose_name': 'Resource', + 'verbose_name_plural': 'Resources', + }, + ), + migrations.AddField( + model_name='action_resource', + name='resource', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Resource', verbose_name='Resource'), + ), + ] diff --git a/core/models.py b/core/models.py index fd18c6e..d7a976e 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,70 @@ from django.db import models - +from django.utils.translation import ugettext_lazy as _ +from users.models import User # Create your models here. + + + + +class Action(models.Model): + """ + It represents an Action on the program by a User such as "create post", + "visualize post", etc. It is supposed to be created everytime we want an aciton + """ + + name = models.CharField(_('Name'), max_length = 100) + created_date = models.DateField(_('Created Date'), auto_now_add=True) + + + def __init__(self, name): + self.name = name + + class Meta: + verbose_name = "Action" + verbose_name_plural = "Actions" + + def __str__(self): + pass + + +class Resource(models.Model): + """ + It represents the resource where the action was applied on. + Example: Pool was answered (Resource: Pool), PDF was visualized(Resource: PDF). + """ + + name = models.CharField(_('Name'), max_length =100) + created_date = models.DateField(_('Created Date'), auto_now_add=True) + class Meta: + verbose_name = "Resource" + verbose_name_plural = "Resources" + + def __str__(self): + pass + + +class Action_Resource(models.Model): + + action = models.ForeignKey(Action , verbose_name= _('Action_Applied')) + resource = models.ForeignKey(Resource, verbose_name = _('Resource')) + + class Meta: + verbose_name = "Action_Resource" + verbose_name_plural = "Action_Resources" + + def __str__(self): + pass + + +class Notification(models.Model): + message = models.TextField(_('message')) + user = models.ForeignKey(User, verbose_name= _('Actor')) + read = models.BooleanField(_('Read'), default=False) + action_resource = models.ForeignKey(Action_Resource, verbose_name = _('Action_Resource')) + + class Meta: + verbose_name = "Action_Resource" + verbose_name_plural = "Action_Resources" + + def __str__(self): + pass diff --git a/users/migrations/0009_auto_20160906_1450.py b/users/migrations/0009_auto_20160906_1450.py new file mode 100644 index 0000000..a073011 --- /dev/null +++ b/users/migrations/0009_auto_20160906_1450.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2016-09-06 17:50 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models +import re + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0008_auto_20160902_2123'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='username', + field=models.CharField(help_text='A short name that will be used to identify you in the platform and to access it', max_length=35, unique=True, validators=[django.core.validators.RegexValidator(re.compile(b'^[\\w.@+-]+$'), 'Type a valid username. This fields should only contain letters, numbers and the characteres: @/./+/-/_ .', b'invalid')], verbose_name='Login'), + ), + ] -- libgit2 0.21.2