Exemple #1
0
def multiple_pups(request):
    """This view is used to enter multiple animals at the same time.
	
    It will generate a form containing animal information and a number of mice.  It is intended to create several identical animals with the same attributes.
    """
    if request.method == "POST":
        form = MultipleAnimalForm(request.POST)
        if form.is_valid():
            count = form.cleaned_data['count']
            for i in range(count):
                animal = Animal(
				    Strain = form.cleaned_data['Strain'], 
					Background = form.cleaned_data['Background'],
					Breeding = form.cleaned_data['Breeding'],
					Cage = form.cleaned_data['Cage'],
                    Rack = form.cleaned_data['Rack'],
                    Rack_Position = form.cleaned_data['Rack_Position'],
                    Genotype = form.cleaned_data['Genotype'],
                    Gender = form.cleaned_data['Gender'],
                    Born = form.cleaned_data['Born'],
                    Weaned = form.cleaned_data['Weaned'],
                    Backcross = form.cleaned_data['Backcross'],
                    Generation = form.cleaned_data['Generation'],
                    Father = form.cleaned_data['Father'],
                    Mother = form.cleaned_data['Mother'],
                    Markings = form.cleaned_data['Markings'],					
                    Notes = form.cleaned_data['Notes'])
                animal.save()
        return HttpResponseRedirect( reverse('strain-list') )	
    else:
        form = MultipleAnimalForm()
    return render_to_response("animal_multiple_form.html", {"form":form,}, context_instance=RequestContext(request))		
Exemple #2
0
def multiple_breeding_pups(request, breeding_id):
    """This view is used to enter multiple animals at the same time from a breeding cage.
	
    It will generate a form containing animal information and a number of mice.  It is intended to create several identical animals with the same attributes.
	This view requres an input of a breeding_id to generate the correct form.
    """
    breeding = Breeding.objects.get(id=breeding_id)
    if request.method == "POST":
        form = MultipleBreedingAnimalForm(request.POST)
        if form.is_valid():
            count = form.cleaned_data['count']
            for i in range(count):
                animal = Animal(
				    Strain = breeding.Strain, 
					Background = breeding.background,
					Breeding = breeding,
					Cage = breeding.Cage,
                    Rack = breeding.Rack,
                    Rack_Position = breeding.Rack_Position,
                    Genotype = breeding.genotype,
                    Gender = form.cleaned_data['Gender'],
                    Born = form.cleaned_data['Born'],
                    Weaned = form.cleaned_data['Weaned'],
                    Backcross = breeding.backcross,
                    Generation = breeding.generation)
                animal.save()	
        return HttpResponseRedirect( breeding.get_absolute_url() )	
    else:
        form = MultipleBreedingAnimalForm()
    return render_to_response("animal_multiple_form.html", {"form":form, "breeding":breeding}, context_instance=RequestContext(request))		
Exemple #3
0
    def test_autoset_active_state(self):
        """This is a test for creating a new breeding object, with only the minimum being entered.  That object is then tested for the active state being automatically set when a End date is specified."""
        example_strain = Strain(Strain="Example Strain")
        example_strain.save()
        new_breeding = Breeding(Strain = example_strain)
        new_breeding.save()
        test_breeding = Breeding.objects.get(Strain=example_strain)
        self.assertEquals(test_breeding.Active, True)
        test_breeding.End = datetime.date.today()
        test_breeding.save()
        self.assertEquals(test_breeding.Active, False)
        print "autoset_breeding_active_state... passed"
		
	def test_male_breeding_location_type(self):
	    """This is a test that the breeding_location_type attribute is being set correctly.
		
        Normal function is that if the breeding cage of a Breeding object and the cage of an Animal object are the same then the breeding male is set to "resident breeder", if not then it is a "non-resident breeder"""
        example_strain = Strain(Strain="Example Strain")
        example_strain.save()
        animal = Animal(Strain = example_strain, Genotype="-/-", Background="Mixed", Cage=1234, Gender='M')
        animal.save()		
        test_breeding = Breeding(Strain = example_strain, Male=animal, Cage=1234)
        test_breeding.save()
        self.assertEquals(test_breeding.male_breeding_location_type, "resident breeder")
        test_breeding_nr = Breeding(Strain = example_strain, Male=animal, Cage=5678)
        self.assertEquals(test_breeding.male_breeding_location_type, "non-resident breeder")
        print "male_breeding_location_type... passed"
Exemple #4
0
 def test_create_animal_minimal(self):
     """This is a test for creating a new animal object, with only the minimum fields being entered"""
     example_strain = Strain(Strain="Example Strain")
     example_strain.save()
     animal = Animal(Strain = example_strain, Genotype="-/-", Background="Mixed")
     animal.save()
     animal_id = animal.id
     self.assertEquals(animal.__unicode__(), "Example Strain (%s)" % animal_id)
     print "create_animal_minimal... passed"
Exemple #5
0
 def test_animal_unicode(self):
     """This is a test for creating a new animal object, with only the minimum fields being entered.  It then tests that the correct unicode representation is being generated."""
     animal = Animal(Strain = Strain.objects.get(pk=1), Genotype="-/-", Background="Mixed")
     animal.save()
     animal_id = animal.id
     self.assertEquals(animal.__unicode__(), "Fixture Strain (5)")
     animal.MouseID = 1234
     animal.save()
     self.assertEquals(animal.__unicode__(), "Fixture Strain-EarTag #1234")
Exemple #6
0
 def test_unicode(self):
     """This is a test for creating a new animal object, with only the minimum fields being entered.  It then tests that the correct unicode representation is being generated."""
     example_strain = Strain(Strain="Example Strain")
     example_strain.save()
     animal = Animal(Strain = example_strain, Genotype="-/-", Background="Mixed")
     animal.save()
     animal_id = animal.id
     self.assertEquals(animal.__unicode__(), "Example Strain (%s)" % animal_id)
     animal.MouseID = 1234
     animal.save()
     self.assertEquals(animal.__unicode__(), "Example Strain-EarTag #1234")
     print "animal_unicode... passed"
Exemple #7
0
 def test_create_animal_minimal(self):
     """This is a test for creating a new animal object, with only the minimum fields being entered"""
     animal = Animal(Strain = Strain.objects.get(pk=1), Genotype="-/-", Background="Mixed")
     animal.save()
     animal_id = animal.id
     self.assertEquals(animal.__unicode__(), "Fixture Strain (5)")