# Path: semillas_backend/users/models.py
# class User(AbstractUser):
# 
#     uuid = models.UUIDField(default=uuid4, editable=False, unique=True)
#     # First Name and Last Name do not cover name patterns
#     # around the globe.
#     name = models.CharField(_('Name of User'), blank=True, max_length=255)
# 
#     phone = PhoneNumberField(blank=True)
#     phone_verified = models.BooleanField(default=False)
# 
#     location = PointField(
#         null=True,
#         blank=True,
#         help_text='User Location, only read in production user admin panel'
#     )
# 
#     location_manually_set = models.BooleanField(
#         default=False,
#         help_text="Flag indicating whether the user has introduced their location or not"
#     )
# 
#     def user_photo_upload(instance, filename):
#         extension = os.path.splitext(filename)[1]
#         return "media/users/%s-%s%s" % (str(instance.id), str(randint(0, 9999)), extension)
# 
#     picture = models.ImageField(
#         null=True,
#         blank=True,
#         help_text='Profile Picture',
#         upload_to=user_photo_upload,
#     )
# 
#     faircoin_address = models.CharField(
#         max_length=36,
#         blank=True,
#         validators=[is_blockchain_address]
#     )
# 
#     telegram_id = models.CharField(
#         blank=True,
#         max_length=60,
#         validators=[starts_with_at],
#         help_text="Telegram Id for peer communication. Example: @username"
#     )
# 
#     def __str__(self):
#         return self.username
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', kwargs={'username': self.username})


from django import forms
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from django.contrib.gis.admin.options import GeoModelAdmin
from django.contrib.staticfiles.templatetags.staticfiles import static
from .models import User
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals



class MyUserChangeForm(UserChangeForm):
    class Meta(UserChangeForm.Meta):
        model = User

class MyUserCreationForm(UserCreationForm):

    error_message = UserCreationForm.error_messages.update({
        'duplicate_username': 'This username has already been taken.'
    })

    class Meta(UserCreationForm.Meta):
        model = User

    def clean_username(self):
        username = self.cleaned_data["username"]
        try:

# Path: semillas_backend/users/models.py
# class User(AbstractUser):
# 
#     uuid = models.UUIDField(default=uuid4, editable=False, unique=True)
#     # First Name and Last Name do not cover name patterns
#     # around the globe.
#     name = models.CharField(_('Name of User'), blank=True, max_length=255)
# 
#     phone = PhoneNumberField(blank=True)
#     phone_verified = models.BooleanField(default=False)
# 
#     location = PointField(
#         null=True,
#         blank=True,
#         help_text='User Location, only read in production user admin panel'
#     )
# 
#     location_manually_set = models.BooleanField(
#         default=False,
#         help_text="Flag indicating whether the user has introduced their location or not"
#     )
# 
#     def user_photo_upload(instance, filename):
#         extension = os.path.splitext(filename)[1]
#         return "media/users/%s-%s%s" % (str(instance.id), str(randint(0, 9999)), extension)
# 
#     picture = models.ImageField(
#         null=True,
#         blank=True,
#         help_text='Profile Picture',
#         upload_to=user_photo_upload,
#     )
# 
#     faircoin_address = models.CharField(
#         max_length=36,
#         blank=True,
#         validators=[is_blockchain_address]
#     )
# 
#     telegram_id = models.CharField(
#         blank=True,
#         max_length=60,
#         validators=[starts_with_at],
#         help_text="Telegram Id for peer communication. Example: @username"
#     )
# 
#     def __str__(self):
#         return self.username
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', kwargs={'username': self.username})


# Path: semillas_backend/users/admin.py
from django import forms
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from django.contrib.gis.admin.options import GeoModelAdmin
from django.contrib.staticfiles.templatetags.staticfiles import static
from .models import User

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



class MyUserChangeForm(UserChangeForm):
    class Meta(UserChangeForm.Meta):
        model = User

class MyUserCreationForm(UserCreationForm):

    error_message = UserCreationForm.error_messages.update({
        'duplicate_username': 'This username has already been taken.'
    })

    class Meta(UserCreationForm.Meta):
        model = User

    def clean_username(self):
        username = self.cleaned_data["username"]
        try:

            User.objects.get(username=username)