diff --git a/src/account/admin.py b/src/account/admin.py index 388129c8f6d559b75b77afdd0cdf57bab932fd9c..37427a6cd7aeb3a160d67350ecb520c66f2e7bf2 100644 --- a/src/account/admin.py +++ b/src/account/admin.py @@ -8,7 +8,7 @@ from . import resources @admin.register(models.Profile) class ProfileAdmin(ExportMixin, admin.ModelAdmin): - list_display = ('user_username', 'join_date') + list_display = ('user_username', 'full_name', 'join_date') resource_class = resources.SignUpResource def user_username(self, obj): diff --git a/src/account/models.py b/src/account/models.py index 0d401930c244a8ea9bbf38f192e12f69dd870bb2..71b79f0c59102fe236def8d5459f6e3170e9f417 100644 --- a/src/account/models.py +++ b/src/account/models.py @@ -29,10 +29,13 @@ class Profile(models.Model): nick = models.CharField(max_length=15, blank=True, default='') signed = models.BooleanField(default=False, null=False) groups = models.ManyToManyField(GroupChoice, related_name='profiles') - # Homeworks=models.ForeignKey(Homework) + + @property + def full_name(self): + return self.user.get_full_name() def __str__(self): - return self.user.username + return self.full_name class Deadline(SingletonModel): diff --git a/src/stats/migrations/0007_auto_20180215_0018.py b/src/stats/migrations/0007_auto_20180215_0018.py new file mode 100644 index 0000000000000000000000000000000000000000..9cd65ce00b95c767f3bf9db33128446d83b79ad2 --- /dev/null +++ b/src/stats/migrations/0007_auto_20180215_0018.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.1 on 2018-02-14 23:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stats', '0006_auto_20180214_2239'), + ] + + operations = [ + migrations.AlterField( + model_name='event', + name='visitors', + field=models.ManyToManyField(related_name='visitor', to='account.Profile'), + ), + ] diff --git a/src/stats/models.py b/src/stats/models.py index 967058c5a5aced81d38a6bbfafef72c53e1e05a5..854def4bdcf72136b6321ef7b52eb2d87f97ca72 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -1,5 +1,5 @@ from django.db import models -from django.contrib.auth.models import User +from account.models import Profile from django.utils import timezone from django.core.exceptions import ValidationError @@ -7,7 +7,7 @@ from django.core.exceptions import ValidationError class Event(models.Model): name = models.CharField(max_length=255) date = models.DateTimeField(null=False) - visitors = models.ManyToManyField(User, related_name='visitor') + visitors = models.ManyToManyField(Profile, related_name='visitor') def clean(self): if self.date > timezone.now(): diff --git a/src/stats/resources.py b/src/stats/resources.py index 2405ffb181c07eaee91519ca302bc91e11a98d36..848f9465de8fdeb289cf40ae337f3a7cde5d9afd 100644 --- a/src/stats/resources.py +++ b/src/stats/resources.py @@ -1,13 +1,13 @@ -from django.contrib.auth.models import User from import_export import resources, widgets, fields +from account.models import Profile from . import models class EventResource(resources.ModelResource): visitors = fields.Field( attribute='visitors', - widget=widgets.ManyToManyWidget(model=User, separator=' ,', field='username'), + widget=widgets.ManyToManyWidget(model=Profile, separator=' ,', field='full_name'), ) class Meta: