# Path: radioco/apps/users/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User, unique=True)
#     bio = RichTextUploadingField(blank=True, verbose_name=_("biography"))
#     avatar = models.ImageField(
#         upload_to='avatars/', default='defaults/default-userprofile-avatar.jpg', verbose_name=_("avatar")
#     )
#     display_personal_page = models.BooleanField(default=False, verbose_name=_("display personal page"))
#     slug = models.SlugField(max_length=30)
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', args=[self.slug])
# 
#     def save(self, *args, **kwargs):
#         if not self.pk:
#             try:
#                 p = UserProfile.objects.get(user=self.user)
#                 self.pk = p.pk
#             except UserProfile.DoesNotExist:
#                 pass
#         self.slug = slugify(self.user.username)
#         super(UserProfile, self).save(*args, **kwargs)
# 
#     class Meta:
#         default_permissions = ('change',)
#         verbose_name = _('user profile')
#         verbose_name_plural = _('user profile')
# 
#     def __str__(self):
#         return "%s's profile" % self.user


import re
from django import forms
from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.core import validators
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from radioco.apps.users.models import UserProfile
    from django.utils.encoding import force_unicode
    from django.utils.encoding import force_text as force_unicode
                name='%s_history' % url_name_prefix
            ),
            url(r'^$',
                self.admin_site.admin_view(self.change_view),
                {'object_id': '-1'},
                name='%s_change' % url_name_prefix
            ),
        ]
        # By inserting the custom URLs first, we overwrite the standard URLs.
        return custom_urls + urls

    def response_change(self, request, obj):
        msg = _('%(obj)s was changed successfully.') % {'obj': force_unicode(obj)}
        if '_continue' in request.POST:
            # self.message_user(request, msg + ' ' + _('You may edit it again below.'))
            return HttpResponseRedirect(request.path)
        else:
            self.message_user(request, msg)
            return HttpResponseRedirect("../../")

    def change_view(self, request, object_id, extra_context=None):
        if object_id == '-1':
            object_id = str(request.user.id)
        return super(SingletonProfileAdmin, self).change_view(
            request,
            object_id,
            extra_context=extra_context,
        )



# Path: radioco/apps/users/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User, unique=True)
#     bio = RichTextUploadingField(blank=True, verbose_name=_("biography"))
#     avatar = models.ImageField(
#         upload_to='avatars/', default='defaults/default-userprofile-avatar.jpg', verbose_name=_("avatar")
#     )
#     display_personal_page = models.BooleanField(default=False, verbose_name=_("display personal page"))
#     slug = models.SlugField(max_length=30)
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', args=[self.slug])
# 
#     def save(self, *args, **kwargs):
#         if not self.pk:
#             try:
#                 p = UserProfile.objects.get(user=self.user)
#                 self.pk = p.pk
#             except UserProfile.DoesNotExist:
#                 pass
#         self.slug = slugify(self.user.username)
#         super(UserProfile, self).save(*args, **kwargs)
# 
#     class Meta:
#         default_permissions = ('change',)
#         verbose_name = _('user profile')
#         verbose_name_plural = _('user profile')
# 
#     def __str__(self):
#         return "%s's profile" % self.user


# Path: radioco/apps/users/admin.py
import re
from django import forms
from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.core import validators
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from radioco.apps.users.models import UserProfile
    from django.utils.encoding import force_unicode
    from django.utils.encoding import force_text as force_unicode

                name='%s_history' % url_name_prefix
            ),
            url(r'^$',
                self.admin_site.admin_view(self.change_view),
                {'object_id': '-1'},
                name='%s_change' % url_name_prefix
            ),
        ]
        # By inserting the custom URLs first, we overwrite the standard URLs.
        return custom_urls + urls

    def response_change(self, request, obj):
        msg = _('%(obj)s was changed successfully.') % {'obj': force_unicode(obj)}
        if '_continue' in request.POST:
            # self.message_user(request, msg + ' ' + _('You may edit it again below.'))
            return HttpResponseRedirect(request.path)
        else:
            self.message_user(request, msg)
            return HttpResponseRedirect("../../")

    def change_view(self, request, object_id, extra_context=None):
        if object_id == '-1':
            object_id = str(request.user.id)
        return super(SingletonProfileAdmin, self).change_view(
            request,
            object_id,
            extra_context=extra_context,
        )



admin.site.register(UserProfile, SingletonProfileAdmin)