Commit e9324074 authored by Tom van Bussel's avatar Tom van Bussel

mailinglists: use User for foreign keys

parent bed79e25
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from members.models import Member
from .models import ListAlias, MailingList, VerbatimAddress
......@@ -15,7 +14,6 @@ class ListAliasInline(admin.TabularInline):
@admin.register(MailingList)
class MailingListAdmin(admin.ModelAdmin):
model = Member
filter_horizontal = ('members',)
inlines = (VerbatimAddressInline, ListAliasInline)
list_display = ('name', 'alias_names',)
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-10-12 10:28
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mailinglists', '0009_auto_20170429_2149'),
]
operations = [
migrations.AddField(
model_name='mailinglist',
name='members_old',
field=models.ManyToManyField(blank=True, help_text='Select individual members to include in the list.', to='members.Member', related_name='members_old'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-10-12 10:28
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
def forward_func(apps, schema_editor):
MailingList = apps.get_model('mailinglists', 'MailingList')
for mailinglist in MailingList.objects.all():
for member in mailinglist.members.all():
mailinglist.members_old.add(member)
class Migration(migrations.Migration):
dependencies = [
('mailinglists', '0010_0_user_foreign_keys'),
]
operations = [
migrations.RunPython(
code=forward_func,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-10-12 10:28
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mailinglists', '0010_1_user_foreign_keys'),
]
operations = [
migrations.RemoveField(
model_name='mailinglist',
name='members',
),
migrations.AddField(
model_name='mailinglist',
name='members',
field=models.ManyToManyField(blank=True, help_text='Select individual members to include in the list.', to=settings.AUTH_USER_MODEL, verbose_name='Members'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-10-12 10:28
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
def forward_func(apps, schema_editor):
MailingList = apps.get_model('mailinglists', 'MailingList')
for mailinglist in MailingList.objects.all():
for member in mailinglist.members_old.all():
mailinglist.members.add(member.user)
class Migration(migrations.Migration):
dependencies = [
('mailinglists', '0010_2_user_foreign_keys'),
]
operations = [
migrations.RunPython(
code=forward_func,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-10-12 10:28
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mailinglists', '0010_3_user_foreign_keys'),
]
operations = [
migrations.RemoveField(
model_name='mailinglist',
name='members_old',
),
]
from django.contrib.auth.models import User
from django.core import validators
from django.core.exceptions import ValidationError
from django.db import models
......@@ -5,7 +6,6 @@ from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from activemembers.models import Committee
from members.models import Member
class MailingList(models.Model):
......@@ -41,7 +41,7 @@ class MailingList(models.Model):
)
members = models.ManyToManyField(
Member,
User,
verbose_name=_("Members"),
blank=True,
help_text=_('Select individual members to include in the list.'),
......
START
{% for member in members %}{{ member.user.email }}
{% for member in members %}{{ member.email }}
{% endfor %}END
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