Last active
January 4, 2016 16:59
-
-
Save eduardo-matos/8651166 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib import admin | |
| from django.utils.translation import ugettext_lazy as _ | |
| from atdfb.core.models import Complaint | |
| class ComplaintAdmin(admin.ModelAdmin): | |
| list_display = ('order_number', 'subject', 'message', 'created_at', 'solved_by', 'checked',) | |
| def get_readonly_fields(self, request, obj=None): | |
| if request.user.has_perm('core.can_edit_fields'): | |
| readonly = ('solved_by',) | |
| else: | |
| readonly = ('name', 'email', 'phone', 'cpf', 'order_number', 'subject', 'message', 'created_at', 'solved_by',) | |
| return readonly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| from django.db import models | |
| from django.utils.translation import ugettext_lazy as _ | |
| from django.contrib.auth import get_user_model | |
| User = get_user_model() | |
| class Complaint(models.Model): | |
| ASSUNTOS = ( | |
| ('alteracao-do-pedido', _(u'Alteração no pedido'),), | |
| ('andamento-da-entrega', _('Andamento da entrega'),), | |
| ('atraso-na-entrega', _('Atraso na entrega'),), | |
| ('cancelamento-de-pedidos', _('Cancelamento de pedidos'),), | |
| ('trocas-e-devolucoes', _(u'Troca e devoluções'),), | |
| ('duvidas-formas-pagamento', _(u'Dúvidas sobre formas de pagamento'),), | |
| ('duvidas-produtos', _(u'Dúvidas sobre o produto'),), | |
| ('pedido-incompleto', _('Pedido incompleto'),), | |
| ('pedido-com-defeito', _('Produto com defeito'),), | |
| ('produto-errado', _('Produto errado'),), | |
| ('vale-compras', _('Vale compras'),), | |
| ('outros', _('Outros'),), | |
| ) | |
| name = models.CharField(_('Nome'), max_length=100, blank=False) | |
| email = models.EmailField(_('E-mail'), blank=False) | |
| phone = models.CharField(_('Telefone'), max_length=15, blank=False) | |
| cpf = models.CharField(_('CPF'), max_length=11, blank=False) | |
| order_number = models.CharField(_(u'Número do pedido'), max_length=40) | |
| subject = models.CharField(_('Assunto'), max_length=50, choices=ASSUNTOS, blank=False) | |
| message = models.TextField(_('Mensagem'), blank=False) | |
| created_at = models.DateTimeField(_('Criado em'), auto_now_add=True) | |
| checked = models.BooleanField(_('Atendido')) | |
| solved_by = models.ForeignKey(User, verbose_name=_('Atendido por'), null=True, blank=True, editable=False) | |
| class Meta: | |
| verbose_name = _(u'Reclamação') | |
| verbose_name_plural = _(u'Reclamações') | |
| permissions = ( | |
| ('can_edit_fields','Can edit fields'), | |
| ) | |
| def __unicode__(self): | |
| return str(self.order_number) + ' - ' + self.subject |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment