Commit 8fe1bf6c308255281cb65278d8edaa829c06eccc
1 parent
ca4dcc0a
Exists in
master
and in
5 other branches
Initial Commit Issues #40 and #39
Showing
3 changed files
with
163 additions
and
1 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,73 @@ |
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +# Generated by Django 1.10 on 2016-09-06 17:50 | |
| 3 | +from __future__ import unicode_literals | |
| 4 | + | |
| 5 | +from django.conf import settings | |
| 6 | +from django.db import migrations, models | |
| 7 | +import django.db.models.deletion | |
| 8 | + | |
| 9 | + | |
| 10 | +class Migration(migrations.Migration): | |
| 11 | + | |
| 12 | + initial = True | |
| 13 | + | |
| 14 | + dependencies = [ | |
| 15 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
| 16 | + ] | |
| 17 | + | |
| 18 | + operations = [ | |
| 19 | + migrations.CreateModel( | |
| 20 | + name='Action', | |
| 21 | + fields=[ | |
| 22 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
| 23 | + ('name', models.CharField(max_length=100, verbose_name='Name')), | |
| 24 | + ('created_date', models.DateField(auto_now_add=True, verbose_name='Created Date')), | |
| 25 | + ], | |
| 26 | + options={ | |
| 27 | + 'verbose_name': 'Action', | |
| 28 | + 'verbose_name_plural': 'Actions', | |
| 29 | + }, | |
| 30 | + ), | |
| 31 | + migrations.CreateModel( | |
| 32 | + name='Action_Resource', | |
| 33 | + fields=[ | |
| 34 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
| 35 | + ('action', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action', verbose_name='Action_Applied')), | |
| 36 | + ], | |
| 37 | + options={ | |
| 38 | + 'verbose_name': 'Action_Resource', | |
| 39 | + 'verbose_name_plural': 'Action_Resources', | |
| 40 | + }, | |
| 41 | + ), | |
| 42 | + migrations.CreateModel( | |
| 43 | + name='Notification', | |
| 44 | + fields=[ | |
| 45 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
| 46 | + ('message', models.TextField(verbose_name='message')), | |
| 47 | + ('read', models.BooleanField(default=False, verbose_name='Read')), | |
| 48 | + ('action_resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action_Resource', verbose_name='Action_Resource')), | |
| 49 | + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Actor')), | |
| 50 | + ], | |
| 51 | + options={ | |
| 52 | + 'verbose_name': 'Action_Resource', | |
| 53 | + 'verbose_name_plural': 'Action_Resources', | |
| 54 | + }, | |
| 55 | + ), | |
| 56 | + migrations.CreateModel( | |
| 57 | + name='Resource', | |
| 58 | + fields=[ | |
| 59 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
| 60 | + ('name', models.CharField(max_length=100, verbose_name='Name')), | |
| 61 | + ('created_date', models.DateField(auto_now_add=True, verbose_name='Created Date')), | |
| 62 | + ], | |
| 63 | + options={ | |
| 64 | + 'verbose_name': 'Resource', | |
| 65 | + 'verbose_name_plural': 'Resources', | |
| 66 | + }, | |
| 67 | + ), | |
| 68 | + migrations.AddField( | |
| 69 | + model_name='action_resource', | |
| 70 | + name='resource', | |
| 71 | + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Resource', verbose_name='Resource'), | |
| 72 | + ), | |
| 73 | + ] | ... | ... |
core/models.py
| 1 | 1 | from django.db import models |
| 2 | - | |
| 2 | +from django.utils.translation import ugettext_lazy as _ | |
| 3 | +from users.models import User | |
| 3 | 4 | # Create your models here. |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | +class Action(models.Model): | |
| 10 | + """ | |
| 11 | + It represents an Action on the program by a User such as "create post", | |
| 12 | + "visualize post", etc. It is supposed to be created everytime we want an aciton | |
| 13 | + """ | |
| 14 | + | |
| 15 | + name = models.CharField(_('Name'), max_length = 100) | |
| 16 | + created_date = models.DateField(_('Created Date'), auto_now_add=True) | |
| 17 | + | |
| 18 | + | |
| 19 | + def __init__(self, name): | |
| 20 | + self.name = name | |
| 21 | + | |
| 22 | + class Meta: | |
| 23 | + verbose_name = "Action" | |
| 24 | + verbose_name_plural = "Actions" | |
| 25 | + | |
| 26 | + def __str__(self): | |
| 27 | + pass | |
| 28 | + | |
| 29 | + | |
| 30 | +class Resource(models.Model): | |
| 31 | + """ | |
| 32 | + It represents the resource where the action was applied on. | |
| 33 | + Example: Pool was answered (Resource: Pool), PDF was visualized(Resource: PDF). | |
| 34 | + """ | |
| 35 | + | |
| 36 | + name = models.CharField(_('Name'), max_length =100) | |
| 37 | + created_date = models.DateField(_('Created Date'), auto_now_add=True) | |
| 38 | + class Meta: | |
| 39 | + verbose_name = "Resource" | |
| 40 | + verbose_name_plural = "Resources" | |
| 41 | + | |
| 42 | + def __str__(self): | |
| 43 | + pass | |
| 44 | + | |
| 45 | + | |
| 46 | +class Action_Resource(models.Model): | |
| 47 | + | |
| 48 | + action = models.ForeignKey(Action , verbose_name= _('Action_Applied')) | |
| 49 | + resource = models.ForeignKey(Resource, verbose_name = _('Resource')) | |
| 50 | + | |
| 51 | + class Meta: | |
| 52 | + verbose_name = "Action_Resource" | |
| 53 | + verbose_name_plural = "Action_Resources" | |
| 54 | + | |
| 55 | + def __str__(self): | |
| 56 | + pass | |
| 57 | + | |
| 58 | + | |
| 59 | +class Notification(models.Model): | |
| 60 | + message = models.TextField(_('message')) | |
| 61 | + user = models.ForeignKey(User, verbose_name= _('Actor')) | |
| 62 | + read = models.BooleanField(_('Read'), default=False) | |
| 63 | + action_resource = models.ForeignKey(Action_Resource, verbose_name = _('Action_Resource')) | |
| 64 | + | |
| 65 | + class Meta: | |
| 66 | + verbose_name = "Action_Resource" | |
| 67 | + verbose_name_plural = "Action_Resources" | |
| 68 | + | |
| 69 | + def __str__(self): | |
| 70 | + pass | ... | ... |
| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +# Generated by Django 1.10 on 2016-09-06 17:50 | |
| 3 | +from __future__ import unicode_literals | |
| 4 | + | |
| 5 | +import django.core.validators | |
| 6 | +from django.db import migrations, models | |
| 7 | +import re | |
| 8 | + | |
| 9 | + | |
| 10 | +class Migration(migrations.Migration): | |
| 11 | + | |
| 12 | + dependencies = [ | |
| 13 | + ('users', '0008_auto_20160902_2123'), | |
| 14 | + ] | |
| 15 | + | |
| 16 | + operations = [ | |
| 17 | + migrations.AlterField( | |
| 18 | + model_name='user', | |
| 19 | + name='username', | |
| 20 | + 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'), | |
| 21 | + ), | |
| 22 | + ] | ... | ... |