Species
This commit is contained in:
		
							parent
							
								
									e397e96dab
								
							
						
					
					
						commit
						3be40fe7da
					
				
					 8 changed files with 76 additions and 14 deletions
				
			
		
							
								
								
									
										0
									
								
								ccdb/species/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								ccdb/species/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										14
									
								
								ccdb/species/admin.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								ccdb/species/admin.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
from django.contrib import admin
 | 
			
		||||
 | 
			
		||||
from .models import Species
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SpeciesAdmin(admin.ModelAdmin):
 | 
			
		||||
    list_display = ('common_name', 'genus', 'species', 'parasite', 'sort_order')
 | 
			
		||||
    list_display_links = ('common_name',)
 | 
			
		||||
    search_fields = ('common_name', 'genus', 'species', 'parasite')
 | 
			
		||||
    list_per_page = 25
 | 
			
		||||
    fields = ('common_name', 'genus', 'species', 'parasite', 'sort_order')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
admin.site.register(Species, SpeciesAdmin)
 | 
			
		||||
							
								
								
									
										34
									
								
								ccdb/species/migrations/0001_initial.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								ccdb/species/migrations/0001_initial.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
# -*- coding: utf-8 -*-
 | 
			
		||||
from __future__ import unicode_literals
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
import autoslug.fields
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.CreateModel(
 | 
			
		||||
            name='Species',
 | 
			
		||||
            fields=[
 | 
			
		||||
                ('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
 | 
			
		||||
                ('common_name', models.CharField(max_length=100)),
 | 
			
		||||
                ('genus', models.CharField(max_length=50, blank=True)),
 | 
			
		||||
                ('species', models.CharField(max_length=50, blank=True)),
 | 
			
		||||
                ('parasite', models.BooleanField(default=False)),
 | 
			
		||||
                ('sort_order', models.IntegerField(blank=True, null=True)),
 | 
			
		||||
                ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='common_name')),
 | 
			
		||||
            ],
 | 
			
		||||
            options={
 | 
			
		||||
                'ordering': ['sort_order'],
 | 
			
		||||
                'verbose_name_plural': 'species',
 | 
			
		||||
            },
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AlterUniqueTogether(
 | 
			
		||||
            name='species',
 | 
			
		||||
            unique_together=set([('common_name', 'species')]),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
							
								
								
									
										0
									
								
								ccdb/species/migrations/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								ccdb/species/migrations/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										20
									
								
								ccdb/species/models.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ccdb/species/models.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
from django.db import models
 | 
			
		||||
 | 
			
		||||
from autoslug import AutoSlugField
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Species(models.Model):
 | 
			
		||||
    common_name = models.CharField(max_length=100)
 | 
			
		||||
    genus = models.CharField(max_length=50, blank=True)
 | 
			
		||||
    species = models.CharField(max_length=50, blank=True)
 | 
			
		||||
    parasite = models.BooleanField(default=False)
 | 
			
		||||
    sort_order = models.IntegerField(blank=True, null=True)
 | 
			
		||||
    slug = AutoSlugField(populate_from='common_name')
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return self.common_name
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        unique_together = ('common_name', 'species')
 | 
			
		||||
        ordering = ['sort_order']
 | 
			
		||||
        verbose_name_plural = 'species'
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue