diff --git a/ietf/doc/migrations/0004_auto_20150403_1235.py b/ietf/doc/migrations/0004_auto_20150403_1235.py new file mode 100644 index 000000000..5f5da077d --- /dev/null +++ b/ietf/doc/migrations/0004_auto_20150403_1235.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + +def set_state(doc, state): + already_set = doc.states.filter(type=state.type) + others = [s for s in already_set if s != state] + if others: + doc.states.remove(*others) + if state not in already_set: + doc.states.add(state) + doc.state_cache = None + +def forward_archive_slides(apps,schema_editor): + Document = apps.get_model('doc', 'Document') + State = apps.get_model('doc','State') + archived = State.objects.get(type__slug='slides',slug='archived') + for doc in Document.objects.filter(name__startswith='slides-92-',states__type__slug='slides',states__slug='active'): + set_state(doc,archived) + +def reverse_archive_slides(apps,schema_editor): + Document = apps.get_model('doc', 'Document') + State = apps.get_model('doc','State') + active = State.objects.get(type__slug='slides',slug='active') + for doc in Document.objects.filter(name__startswith='slides-92-',states__type__slug='slides',states__slug='archived'): + set_state(doc,active) + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0003_auto_20150326_0728'), + ] + + operations = [ + migrations.RunPython(forward_archive_slides,reverse_archive_slides), + ] diff --git a/ietf/secr/proceedings/views.py b/ietf/secr/proceedings/views.py index da210f07a..79ca225ea 100644 --- a/ietf/secr/proceedings/views.py +++ b/ietf/secr/proceedings/views.py @@ -912,9 +912,10 @@ def upload_unified(request, meeting_num, acronym=None, session_id=None): handle_upload_file(file,disk_filename,meeting,material_type.slug) # set Doc state - state = State.objects.get(type=doc.type,slug='active') - doc.set_state(state) - doc.set_state(State.objects.get(type='reuse_policy',slug='single')) + state = State.objects.get(type=doc.type,slug='active' if doc.type.slug!='slides' else 'archived') + if doc.type.slug=='slides': + doc.set_state(state) + doc.set_state(State.objects.get(type='reuse_policy',slug='single')) # create session relationship, per Henrik we should associate documents to all sessions # for the current meeting (until tools support different materials for diff sessions)