-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #740 from hackerspace-ntnu/677-mulig-å-godkjenne-e…
…get-oppmøte-på-arrangementer Mulig å godkjenne eget oppmøte på arrangementer
- Loading branch information
Showing
9 changed files
with
1,341 additions
and
563 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Generated by Django 3.2.17 on 2023-03-28 18:44 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
def to_responsible_list(apps, schema_editor): | ||
Event = apps.get_model('news', 'Event') | ||
Event_responsible = apps.get_model('news', 'Event_responsible') | ||
for event in Event.objects.all(): | ||
if event.responsible: | ||
Event_responsible.objects.create(event=event, responsible=event.responsible) | ||
event.save() | ||
|
||
def reverse_to_responsible_list(apps, schema_editor): | ||
Event = apps.get_model('news', 'Event') | ||
for event in Event.objects.all(): | ||
responsibles = event.responsibles.all() | ||
if responsibles: | ||
event.responsible = responsibles.first() | ||
event.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('news', '0032_alter_article_main_content'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='event', | ||
options={'ordering': ('time_start',), 'permissions': (('can_view_internal_event', 'Can see internal events'),)}, | ||
), | ||
migrations.CreateModel( | ||
name='Event_responsible', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='news.event')), | ||
('responsible', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='event', | ||
name='responsibles', | ||
field=models.ManyToManyField(related_name='responsibles', through='news.Event_responsible', to=settings.AUTH_USER_MODEL, verbose_name='Arrangementansvarlig'), | ||
), | ||
migrations.RunPython( | ||
to_responsible_list, | ||
reverse_to_responsible_list | ||
), | ||
migrations.RemoveField( | ||
model_name='event', | ||
name='responsible', | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters