# Path: profiles/models.py
# class UserProfile(models.Model):
#     """A user profile."""
#     user = models.ForeignKey(User)
#     feeds = models.ManyToManyField(to=Feed, through='profiles.Subscription')
#     entries = models.ManyToManyField(to=Entry,
#                                      through='profiles.UserEntryDetail')
#     next_slug = RandomSlugField(slug_length=10)
# 
#     def __unicode__(self):
#         return u"{}'s profile".format(self.user.username)
# 
#     def subscribe(self, feed):
#         Subscription.objects.create(profile=self, feed=feed)
# 
#     def unsubscribe(self, feed):
#         Subscription.objects.get(profile=self, feed=feed).delete()
#         self._get_entries(feed).delete()
# 
#     def mark_read(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = True
#             entry.save()
# 
#     def mark_unread(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = False
#             entry.save()
# 
#     def unread_entries(self, feed):
#         return self._get_entries(feed).filter(read=False).count()
# 
#     def _get_entries(self, feed):
#         return UserEntryDetail.objects.filter(profile=self, entry__feed=feed)
# 
# class UserEntryDetail(models.Model):
#     profile = models.ForeignKey(to=UserProfile)
#     entry = models.ForeignKey(to=Entry)
#     read = models.BooleanField()
# 
#     def __unicode__(self):
#         return u'User: {}, Entry: {}, Read: {}'.format(
#                                                 self.profile.user.username,
#                                                 self.entry,
#                                                 self.read)


from django.contrib import admin
from profiles.models import UserProfile, UserEntryDetail



class UserProfileAdmin(admin.ModelAdmin):
    readonly_fields = ('user', 'next_slug')

admin.site.register(UserProfile, UserProfileAdmin)

# Path: profiles/models.py
# class UserProfile(models.Model):
#     """A user profile."""
#     user = models.ForeignKey(User)
#     feeds = models.ManyToManyField(to=Feed, through='profiles.Subscription')
#     entries = models.ManyToManyField(to=Entry,
#                                      through='profiles.UserEntryDetail')
#     next_slug = RandomSlugField(slug_length=10)
# 
#     def __unicode__(self):
#         return u"{}'s profile".format(self.user.username)
# 
#     def subscribe(self, feed):
#         Subscription.objects.create(profile=self, feed=feed)
# 
#     def unsubscribe(self, feed):
#         Subscription.objects.get(profile=self, feed=feed).delete()
#         self._get_entries(feed).delete()
# 
#     def mark_read(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = True
#             entry.save()
# 
#     def mark_unread(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = False
#             entry.save()
# 
#     def unread_entries(self, feed):
#         return self._get_entries(feed).filter(read=False).count()
# 
#     def _get_entries(self, feed):
#         return UserEntryDetail.objects.filter(profile=self, entry__feed=feed)
# 
# class UserEntryDetail(models.Model):
#     profile = models.ForeignKey(to=UserProfile)
#     entry = models.ForeignKey(to=Entry)
#     read = models.BooleanField()
# 
#     def __unicode__(self):
#         return u'User: {}, Entry: {}, Read: {}'.format(
#                                                 self.profile.user.username,
#                                                 self.entry,
#                                                 self.read)


# Path: profiles/admin.py
from django.contrib import admin
from profiles.models import UserProfile, UserEntryDetail




class UserProfileAdmin(admin.ModelAdmin):
    readonly_fields = ('user', 'next_slug')

admin.site.register(UserProfile, UserProfileAdmin)

admin.site.register(UserEntryDetail)