Commit 336de7a7 authored by Bruno Martin's avatar Bruno Martin

remove policial related fields and add migration

parent 498de9d5
Pipeline #7976 passed with stage
in 59 seconds
# Generated by Django 2.2.4 on 2019-08-24 16:05
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='user',
name='accepted_terms',
field=models.BooleanField(default=False, verbose_name='Accepted terms and condition'),
),
migrations.AddField(
model_name='user',
name='address',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Address'),
),
migrations.AddField(
model_name='user',
name='address_extra',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Extra information for address'),
),
migrations.AddField(
model_name='user',
name='address_number',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Address number'),
),
migrations.AddField(
model_name='user',
name='birth_date',
field=models.DateField(blank=True, null=True, verbose_name='Birth Date'),
),
migrations.AddField(
model_name='user',
name='cpf',
field=models.CharField(blank=True, max_length=11, null=True, unique=True),
),
migrations.AddField(
model_name='user',
name='institution',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='user',
name='neighborhood',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Neighborhood'),
),
migrations.AddField(
model_name='user',
name='phone_number',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Phone number'),
),
migrations.AddField(
model_name='user',
name='phone_number_other',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Other phone number'),
),
migrations.AddField(
model_name='user',
name='sexual_orientation',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Sexual orientation'),
),
migrations.AddField(
model_name='user',
name='sexual_orientation_other',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Other sexual orientation'),
),
migrations.AddField(
model_name='user',
name='site',
field=models.URLField(blank=True, verbose_name='Site'),
),
migrations.AddField(
model_name='user',
name='social_facebook',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Facebook'),
),
migrations.AddField(
model_name='user',
name='social_google',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Google'),
),
migrations.AddField(
model_name='user',
name='social_skype',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Skype'),
),
migrations.AddField(
model_name='user',
name='social_twitter',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Twitter'),
),
migrations.AddField(
model_name='user',
name='zipcode',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='ZIP Code'),
),
migrations.AlterField(
model_name='user',
name='city',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='users', to='cities_light.City', verbose_name='City'),
),
migrations.AlterField(
model_name='user',
name='country',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='users', to='cities_light.Country', verbose_name='Country'),
),
migrations.AlterField(
model_name='user',
name='date_joined',
field=models.DateTimeField(auto_now_add=True, verbose_name='Date joined'),
),
migrations.AlterField(
model_name='user',
name='last_name',
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
),
migrations.AlterField(
model_name='user',
name='state',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='users', to='cities_light.Region', verbose_name='Region'),
),
]
......@@ -12,50 +12,6 @@ import hashlib
import re
class PoliticalFront(models.Model):
name = models.CharField(
_('Name'),
max_length=255,
unique=True
)
def __str__(self):
return self.name
class Meta:
verbose_name = _('Political Front')
verbose_name_plural = _('Political Fronts')
class ActivismSchoolWorkplace(models.Model):
name = models.CharField(
_('Name'),
max_length=255,
unique=True
)
def __str__(self):
return self.name
class Meta:
verbose_name = _('Activism School Workplace')
verbose_name_plural = _('Activism School Workplaces')
class Event(models.Model):
name = models.CharField(
_('Name'),
max_length=255,
unique=True
)
def __str__(self):
return self.name
class Meta:
verbose_name = _('Event')
verbose_name_plural = _('Events')
class User(AbstractUser):
RACE_CHOICES = (
......@@ -249,48 +205,6 @@ class User(AbstractUser):
blank=True
)
# Political info
political_front = models.ManyToManyField(
PoliticalFront,
verbose_name=_('Political front'),
related_name='users',
blank=True
)
political_front_other = models.CharField(
_('Other political front'),
null=True, max_length=255,
blank=True
)
studies = models.NullBooleanField(
_('Studies'),
blank=True
)
school = models.CharField(
_('School'),
null=True, max_length=255,
blank=True
)
activism_school_workplace = models.ManyToManyField(
ActivismSchoolWorkplace,
verbose_name=_('Activism in school and/or workplace'),
related_name='users',
blank=True
)
activism_school_workplace_other = models.CharField(
_('Other activism form in school and/or workplace'),
null=True, max_length=255,
blank=True
)
has_mandate = models.NullBooleanField(
_('Has a mandate'),
blank=True
)
mandate = models.CharField(
_('Mandate'),
null=True, max_length=255,
blank=True
)
# Legacy stuff
cpf = models.CharField(max_length=11, blank=True, null=True, unique=True)
institution = models.CharField(max_length=255, blank=True, null=True)
......@@ -379,5 +293,5 @@ class User(AbstractUser):
return True
def get_certificates(self):
from core.models import CourseCertification
from courses_certification.models import CourseCertification
return CourseCertification.objects.filter(course_student__user=self)
......@@ -12,7 +12,6 @@ from cities_light.models import City, Region
import requests
from .models import PoliticalFront, ActivismSchoolWorkplace
User = get_user_model()
......@@ -89,20 +88,6 @@ class RegistrationSerializer(RegisterSerializer):
return user
class PoliticalFrontSerializer(serializers.ModelSerializer):
class Meta:
model = PoliticalFront
fields = ('id', 'name')
class ActivismSchoolWorkplaceSerializer(serializers.ModelSerializer):
class Meta:
model = ActivismSchoolWorkplace
fields = ('id', 'name')
class FixSocialLoginSerializer(SocialLoginSerializer):
def validate(self, attrs):
view = self.context.get('view')
......
......@@ -8,8 +8,6 @@ from . import views
router = SimpleRouter()
router.register(r'', views.UserViewSet)
router.register(r'political-front', views.PoliticalFrontViewSet),
router.register(r'activism-school-workplace', views.ActivismSchoolWorkplaceViewSet),
# router.register(r'stats', views.StatsViewSet, base_name='user_stats'),
app_name = 'users'
......
......@@ -24,11 +24,9 @@ from rest_auth.social_serializers import TwitterLoginSerializer, TwitterConnectS
from courier.emails.serializers import EmailProfileSerializer
from courier.emails.models import EmailProfile
from .models import PoliticalFront, ActivismSchoolWorkplace
from .permissions import IsCurrentUserOrAdmin
from .serializers import (
UserSerializer, FixSocialLoginSerializer, SimpleUserSerializer,
PoliticalFrontSerializer, ActivismSchoolWorkplaceSerializer,
)
User = get_user_model()
......@@ -233,16 +231,6 @@ class SimpleUserViewSet(generics.GenericAPIView, mixins.RetrieveModelMixin):
lookup_field = ('username', 'email')
class PoliticalFrontViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = PoliticalFrontSerializer
queryset = PoliticalFront.objects.all()
class ActivismSchoolWorkplaceViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = ActivismSchoolWorkplaceSerializer
queryset = ActivismSchoolWorkplace.objects.all()
# FIXME: the social classes may need rework when updating to v0.9.3
# FixSocialLoginSerializer class may not be needed anymore
class FacebookLogin(SocialLoginView):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment