Experiment-Collection
This commit is contained in:
parent
7c1b12f833
commit
8114bb9f2c
4 changed files with 29 additions and 1 deletions
|
@ -17,7 +17,7 @@ class ExperimentAdmin(admin.ModelAdmin):
|
|||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'code', 'description', 'flaw', 'sort_order')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'code', 'description', 'flaw', 'sort_order')
|
||||
fields = ('name', 'code', 'description', 'flaw', 'collections', 'sort_order')
|
||||
|
||||
|
||||
class ProtocolAttachmentAdmin(admin.ModelAdmin):
|
||||
|
|
20
ccdb/experiments/migrations/0006_experiment_collections.py
Normal file
20
ccdb/experiments/migrations/0006_experiment_collections.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('collections_ccdb', '0001_initial'),
|
||||
('experiments', '0005_alivedeadcount'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='experiment',
|
||||
name='collections',
|
||||
field=models.ManyToManyField(to='collections_ccdb.Collection'),
|
||||
),
|
||||
]
|
|
@ -23,6 +23,7 @@ class Experiment(models.Model):
|
|||
flaw = models.ForeignKey(Flaw, blank=True, null=True)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
collections = models.ManyToManyField('collections_ccdb.Collection')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
|
|
@ -269,3 +269,10 @@ def _import_admin_data():
|
|||
status_date=r[12], status_time=r[13], count_alive=r[4],
|
||||
count_dead=r[5], flaw=flaw)
|
||||
adc.save()
|
||||
|
||||
# Experiment-Collection
|
||||
for r in c.execute('SELECT * FROM tbl_hash_collection_experiments;'):
|
||||
c = Collection.objects.get(id=r[0])
|
||||
e = Experiment.objects.get(id=r[1])
|
||||
e.collections.add(c)
|
||||
e.save()
|
||||
|
|
Loading…
Add table
Reference in a new issue