Commit a35aa3df authored by Alexandre's avatar Alexandre

Merge branch 'dev'

parents 74013517 88541082
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-17 21:27
# Generated by Django 1.11.21 on 2019-07-08 09:50
from __future__ import unicode_literals
from django.conf import settings
......@@ -12,8 +12,8 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('djangoldp_conversation', '0003_auto_20190503_0323'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
......@@ -32,8 +32,9 @@ class Migration(migrations.Migration):
('lat', models.DecimalField(blank=True, decimal_places=12, max_digits=15, null=True, verbose_name='Latitude')),
('lng', models.DecimalField(blank=True, decimal_places=12, max_digits=15, null=True, verbose_name='Longitude')),
('crowdfunding', models.URLField(blank=True, max_length=9999999, null=True, verbose_name='Lien vers campagne de financement')),
('start_time', models.CharField(blank=True, max_length=255, null=True, verbose_name='Heure de début')),
('start_time', models.CharField(max_length=255, verbose_name='Heure de début')),
('end_time', models.CharField(blank=True, max_length=255, null=True, verbose_name='Heure de fin')),
('closed', models.BooleanField(default=False, verbose_name='Groupe clôturé')),
('actions', models.ManyToManyField(blank=True, related_name='_action_actions_+', to='data_manager.Action')),
('author', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_actions', to=settings.AUTH_USER_MODEL)),
('conversation', models.ManyToManyField(blank=True, to='djangoldp_conversation.Conversation')),
......@@ -77,8 +78,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('photo', models.URLField(blank=True, max_length=9999999, verbose_name='URL de la photo')),
('city', models.CharField(max_length=255, verbose_name='Ville')),
('postcode', models.CharField(max_length=255, verbose_name='Code postal')),
('city', models.CharField(blank=True, max_length=255, null=True, verbose_name='Ville')),
('postcode', models.CharField(blank=True, max_length=255, null=True, verbose_name='Code postal')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='userprofile', to=settings.AUTH_USER_MODEL, verbose_name='Utilisateur')),
],
),
......@@ -90,7 +91,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='action',
name='members',
field=models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL),
field=models.ManyToManyField(blank=True, related_name='actions', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='action',
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-18 21:01
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='actiontheme',
options={'default_permissions': ('add', 'change', 'delete', 'view', 'control')},
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-19 17:52
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0002_auto_20190618_2301'),
]
operations = [
migrations.AlterField(
model_name='userprofile',
name='city',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Ville'),
),
migrations.AlterField(
model_name='userprofile',
name='postcode',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Code postal'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-19 22:26
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0003_auto_20190619_1952'),
]
operations = [
migrations.AlterField(
model_name='action',
name='start_time',
field=models.CharField(default=1, max_length=255, verbose_name='Heure de début'),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-26 20:38
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0004_auto_20190620_0026'),
]
operations = [
migrations.AddField(
model_name='action',
name='closed',
field=models.BooleanField(default=False, verbose_name='Groupe clôturé ?'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-26 20:39
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0005_action_closed'),
]
operations = [
migrations.AlterField(
model_name='action',
name='closed',
field=models.BooleanField(default=False, verbose_name='Groupe clôturé'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-07-02 09:34
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0006_auto_20190626_2239'),
]
operations = [
migrations.AlterField(
model_name='action',
name='members',
field=models.ManyToManyField(blank=True, related_name='actions', to=settings.AUTH_USER_MODEL),
),
]
......@@ -15,13 +15,13 @@ import itertools
Conversation._meta.permission_classes = [ThreadPermission]
User._meta.serializer_fields = ['@id', 'username', 'first_name', 'last_name', 'email', 'actions', 'created_actions', 'get_full_name', 'userprofile']
User._meta.rdf_context = {"get_full_name": "rdfs:label", "photo": "foaf:depiction"}
User._meta.serializer_fields = ['@id', 'username', 'first_name', 'last_name', 'email', 'actions', 'active_actions', 'created_actions', 'get_full_name', 'userprofile']
User._meta.rdf_context = {"get_full_name": "rdfs:label"}
User._meta.depth = 0
User._meta.get_field('username').verbose_name = "Email"
#def active_actions(self):
# return json.dumps(list(self.actions.filter(date__gte=date.today())))
#User.active_actions=active_actions
User._meta.get_field('username').verbose_name = "Email"
def active_actions(self):
return self.actions.filter(date__gte=date.today())
User.active_actions=active_actions
class UserProfile(Model):
photo = models.URLField(max_length=9999999, blank=True, verbose_name=u"URL de la photo")
......
......@@ -10,7 +10,7 @@ urlpatterns = [
url(r'^api/quit_action/(?P<pk>\d+)/', views.quit_action, name='quit_action'),
# API:
url(r'^api/users/', LDPViewSet.urls( model=User, fields = ['@id','first_name', 'last_name', 'username', 'email', 'actions', 'created_actions', 'get_full_name', 'userprofile'], nested_fields=['actions', 'created_actions', 'userprofile'], permission_classes=(),)),
url(r'^api/users/', LDPViewSet.urls( model=User, fields = ['@id','first_name', 'last_name', 'username', 'email', 'actions', 'active_actions', 'created_actions', 'get_full_name', 'userprofile'], nested_fields=['actions', 'created_actions', 'userprofile'], permission_classes=(),)),
url(r'^api/active-actions/', ActionViewSet.urls()),
url(r'^api/', include('djangoldp.urls')),
]
......@@ -15,10 +15,10 @@ class EmailRegistrationForm(RegistrationForm):
def clean_email(self):
if User.objects.filter(username=self.cleaned_data['email']).exists():
raise ValidationError("Un utilisateur avec cette adresse email existe déjà.")
self.instance.username = self.cleaned_data['email']
return self.cleaned_data['email']
def save(self):
self.instance.username = self.instance.email
user = super().save()
self.instance.userprofile = UserProfile(postcode=self.cleaned_data['postcode'], user=user)
user.userprofile.save()
......
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