Skip to content
Snippets Groups Projects
Commit f0ecc985 authored by Barnabás Czémán's avatar Barnabás Czémán
Browse files

Change export visitors to full_name

parent b42b0727
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ from . import resources ...@@ -8,7 +8,7 @@ from . import resources
@admin.register(models.Profile) @admin.register(models.Profile)
class ProfileAdmin(ExportMixin, admin.ModelAdmin): class ProfileAdmin(ExportMixin, admin.ModelAdmin):
list_display = ('user_username', 'join_date') list_display = ('user_username', 'full_name', 'join_date')
resource_class = resources.SignUpResource resource_class = resources.SignUpResource
def user_username(self, obj): def user_username(self, obj):
......
...@@ -29,10 +29,13 @@ class Profile(models.Model): ...@@ -29,10 +29,13 @@ class Profile(models.Model):
nick = models.CharField(max_length=15, blank=True, default='') nick = models.CharField(max_length=15, blank=True, default='')
signed = models.BooleanField(default=False, null=False) signed = models.BooleanField(default=False, null=False)
groups = models.ManyToManyField(GroupChoice, related_name='profiles') 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): def __str__(self):
return self.user.username return self.full_name
class Deadline(SingletonModel): class Deadline(SingletonModel):
......
# 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'),
),
]
from django.db import models from django.db import models
from django.contrib.auth.models import User from account.models import Profile
from django.utils import timezone from django.utils import timezone
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
...@@ -7,7 +7,7 @@ from django.core.exceptions import ValidationError ...@@ -7,7 +7,7 @@ from django.core.exceptions import ValidationError
class Event(models.Model): class Event(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
date = models.DateTimeField(null=False) date = models.DateTimeField(null=False)
visitors = models.ManyToManyField(User, related_name='visitor') visitors = models.ManyToManyField(Profile, related_name='visitor')
def clean(self): def clean(self):
if self.date > timezone.now(): if self.date > timezone.now():
......
from django.contrib.auth.models import User
from import_export import resources, widgets, fields from import_export import resources, widgets, fields
from account.models import Profile
from . import models from . import models
class EventResource(resources.ModelResource): class EventResource(resources.ModelResource):
visitors = fields.Field( visitors = fields.Field(
attribute='visitors', attribute='visitors',
widget=widgets.ManyToManyWidget(model=User, separator=' ,', field='username'), widget=widgets.ManyToManyWidget(model=Profile, separator=' ,', field='full_name'),
) )
class Meta: class Meta:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment