diff --git a/core/models.py b/core/models.py index e0c1984..7ebc87f 100644 --- a/core/models.py +++ b/core/models.py @@ -6,20 +6,20 @@ from autoslug.fields import AutoSlugField class Action(models.Model): """ - It represents an Action on the program by a User such as "create post", + 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) - + class Meta: verbose_name = "Action" verbose_name_plural = "Actions" def __str__(self): return self.name - + class Resource(models.Model): """ @@ -27,38 +27,38 @@ class Resource(models.Model): Example: Pool was answered (Resource: Pool), PDF was visualized(Resource: PDF). Attributes: - @name: name of the resource affected, it will be unique because a resource can be affecte + @name: name of the resource affected, it will be unique because a resource can be affecte by a huge amount of actions @created_date: The date the resource was created @link: Which URL made that resource able to find """ name = models.CharField(_('Name'), max_length =100) - slug = AutoSlugField(_("Slug"), populate_from='name', unique=True, null=True) + slug = AutoSlugField(_("Slug"), populate_from='name', unique=True) created_date = models.DateField(_('Created Date'), auto_now_add=True) url = models.CharField(_('URL'), max_length =100, default="") class Meta: verbose_name = "Resource" - verbose_name_plural = "Resources" + verbose_name_plural = "Resources" def __str__(self): return self.name 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): return ''.join([self.action.name, " / ", self.resource.name]) - + class Notification(models.Model): """ @@ -77,7 +77,7 @@ class Notification(models.Model): datetime = models.DateTimeField(_("Date and Time of action"), auto_now_add = True) action_resource = models.ForeignKey(Action_Resource, verbose_name = _('Action_Resource')) actor = models.ForeignKey(User, related_name = _('%(class)s_Performer'), verbose_name= _('Perfomer'), null = True) - + class Meta: verbose_name = _("Notification") verbose_name_plural = _("Notifications") diff --git a/poll/admin.py b/poll/admin.py index 8c38f3f..1f18fc3 100644 --- a/poll/admin.py +++ b/poll/admin.py @@ -1,3 +1,14 @@ from django.contrib import admin -# Register your models here. +from .models import Poll, Answer + +class PollAdmin(admin.ModelAdmin): + list_display = ['name', 'slug','limit_date'] + search_fields = ['name','slug'] + +class AnswerAdmin(admin.ModelAdmin): + list_display = ['answer','order'] + search_fields = ['answer'] + +admin.site.register(Poll, PollAdmin) +admin.site.register(Answer, AnswerAdmin) diff --git a/poll/forms.py b/poll/forms.py new file mode 100644 index 0000000..570d90d --- /dev/null +++ b/poll/forms.py @@ -0,0 +1,22 @@ +from django import forms +from django.utils.translation import ugettext_lazy as _ +from users.models import User +from .models import Poll + +class PollForm(forms.ModelForm): + + # password = forms.CharField(label=_('Password'), widget=forms.PasswordInput) + # password2 = forms.CharField(label = _('Password confirmation'), widget = forms.PasswordInput) + # birth_date = forms.DateField(widget=forms.SelectDateWidget()) + # MIN_LENGTH = 8 + + class Meta: + model = Poll + # exclude = ['is_staff', 'is_active'] + fields = ['name','limit_date'] + + widgets = { + 'name': forms.TextInput(attrs={'placeholder': 'Question?'}), + 'description': forms.DateTimeInput( + attrs={'placeholder': 'Maximum date permited to resolve the poll'}), + } diff --git a/poll/templates/poll/poll.html b/poll/templates/poll/poll.html index b2794de..c6ca07a 100644 --- a/poll/templates/poll/poll.html +++ b/poll/templates/poll/poll.html @@ -1,52 +1,173 @@ {% extends "topic/index.html" %} -{% load i18n %} +{% load i18n widget_tweaks dict_access static%} {% block style %} {% endblock %} {% block content %} -