# Path: catalog/reviews/models.py
# class Review(models.Model):
#     """
#     Model for product reviews.
#     """
#     RATING_CHOICES = tuple((x, x) for x in range(1, 6))
# 
#     product = models.ForeignKey(
#         Product, related_name='reviews', verbose_name=_('Product'))
#     user = models.ForeignKey(
#         USER_MODEL, blank=True, null=True, verbose_name=_('User'))
#     session_key = models.CharField(
#         _('Session key'), max_length=255, blank=True)
# 
#     body = models.TextField(_('Body'), max_length=1024, blank=True)
# 
#     rating = models.PositiveIntegerField(
#         _('Rating'), max_length=1,
#         choices=RATING_CHOICES, default=RATING_CHOICES[0][0])
# 
#     date_added = models.DateTimeField(_('Date added'), auto_now_add=True)
#     last_modified = models.DateTimeField(_('Last modified'), auto_now=True)
# 
#     class Meta:
#         db_table = 'catalog_reviews_reviews'
#         verbose_name = _('Review')
#         verbose_name_plural = _('Reviews')
#         unique_together = ('product', 'user')
#         ordering = ('-date_added', )
# 
#     def __str__(self):
#         return '{}...'.format(self.body[:13])
# 
#     def get_absolute_url(self):
#         return reverse(
#             'catalog_review_detail', args=[self.product.get_slug(), self.pk])


from django.contrib import admin
from django.contrib.admin.options import ModelAdmin
from catalog.reviews.models import Review
# -*- coding: utf-8 -*-
from __future__ import unicode_literals




class ReviewAdmin(ModelAdmin):
    list_display = ('__str__', 'rating', 'product', 'user')
    search_fields = ('body', 'product__pk', 'user__username')
    list_filter = ('rating', 'product', 'user')
    raw_id_fields = ('product', 'user')

    fieldsets = (
        (None, {
            'fields': ('product', 'user', ),
        }),
        (None, {
            'fields': ('body', 'rating'),
        }),
    )



# Path: catalog/reviews/models.py
# class Review(models.Model):
#     """
#     Model for product reviews.
#     """
#     RATING_CHOICES = tuple((x, x) for x in range(1, 6))
# 
#     product = models.ForeignKey(
#         Product, related_name='reviews', verbose_name=_('Product'))
#     user = models.ForeignKey(
#         USER_MODEL, blank=True, null=True, verbose_name=_('User'))
#     session_key = models.CharField(
#         _('Session key'), max_length=255, blank=True)
# 
#     body = models.TextField(_('Body'), max_length=1024, blank=True)
# 
#     rating = models.PositiveIntegerField(
#         _('Rating'), max_length=1,
#         choices=RATING_CHOICES, default=RATING_CHOICES[0][0])
# 
#     date_added = models.DateTimeField(_('Date added'), auto_now_add=True)
#     last_modified = models.DateTimeField(_('Last modified'), auto_now=True)
# 
#     class Meta:
#         db_table = 'catalog_reviews_reviews'
#         verbose_name = _('Review')
#         verbose_name_plural = _('Reviews')
#         unique_together = ('product', 'user')
#         ordering = ('-date_added', )
# 
#     def __str__(self):
#         return '{}...'.format(self.body[:13])
# 
#     def get_absolute_url(self):
#         return reverse(
#             'catalog_review_detail', args=[self.product.get_slug(), self.pk])


# Path: catalog/reviews/admin.py
from django.contrib import admin
from django.contrib.admin.options import ModelAdmin
from catalog.reviews.models import Review

# -*- coding: utf-8 -*-
from __future__ import unicode_literals




class ReviewAdmin(ModelAdmin):
    list_display = ('__str__', 'rating', 'product', 'user')
    search_fields = ('body', 'product__pk', 'user__username')
    list_filter = ('rating', 'product', 'user')
    raw_id_fields = ('product', 'user')

    fieldsets = (
        (None, {
            'fields': ('product', 'user', ),
        }),
        (None, {
            'fields': ('body', 'rating'),
        }),
    )



admin.site.register(Review, ReviewAdmin)