biodiversity package
biodiversity.models module
- class biodiversity.models.Answer(id, question, text, is_described, is_extra, has_area, score_when_selected, order)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- normalised_species_score(num_of_answers)
Returns the normalised score for this answer. minus 1 because ‘None of the above’ is not to be evaluated. I’m not happy about it either. - Scott
- score()
Returns the total achievable score for this answer.
- class biodiversity.models.Assessment(id, name, farm, slug, biome, total_area, species_total, input_data)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- answer_set()
Returns the answers for the assessment
- calculate_general_score(component)
Calculates the general score for the assessment
- property calculate_land_use
Calculates the land use score for the assessment
- property calculate_species_score
Calculates the species score for the assessment
- static get_max_score_for_component(component_id, assessment)
Given a component id, return the maximum score for that component. param component_id: the id of the component param assessment: the assessment object
- get_score_for_component(component)
Gets the score for a component using the Users input data from the db answers that are NORMALIZED use a separate formula:
score = ((answer_score / question_max_score) * answer_normalized_score)
answers that are NOT scored when selected and initially summed to the questions full score, any subsequent answers added to the assessment are subtracted from the question’s max score.
- property get_species_score
Gets the species score for the assessment
- class biodiversity.models.AssessmentAnswers(*args, **kwargs)
Bases:
django.db.models.base.Model
Model for recording the answers to an assessment.
- exception DoesNotExist
- exception MultipleObjectsReturned
- class biodiversity.models.Biome(id, name, slug, description, active)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- save(*args, **kwargs)
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class biodiversity.models.Component(id, name, slug, help_text, area, biome)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- get_max_score(assessment)
Gets the maximum score for this component from current assessment’s Questions, ignoring any questions that normalize with an answer.
- class biodiversity.models.GeneralScore(id, answer, clm, cambridge)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- class biodiversity.models.GeneralScoreTotal(id, assessment, component, score)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- class biodiversity.models.ManagementArea(id, name, slug)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- class biodiversity.models.Question(id, component, text, is_multiple_choice, normalise_with_answer, order)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- max_score()
Returns the highest score for this question.
- class biodiversity.models.ScopeArea(id, name, slug)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- save(*args, **kwargs)
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class biodiversity.models.SpeciesGroup(id, name, slug, order)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
- class biodiversity.models.SpeciesGroupScore(id, answer, species_group, clm, cambridge)
Bases:
django.db.models.base.Model
- exception DoesNotExist
- exception MultipleObjectsReturned
biodiversity.pdf module
biodiversity.views module
- class biodiversity.views.AssessmentDeleteView(**kwargs)
Bases:
biodiversity.views.BiodiversityMixin
,django.views.generic.edit.DeleteView
- model
alias of
biodiversity.models.Assessment
- class biodiversity.views.AssessmentExportView(**kwargs)
Bases:
django.views.generic.detail.DetailView
,farm.views.ExcelResponseMixin
- model
alias of
biodiversity.models.Assessment
- render_to_response(context, **response_kwargs)
Return a response, using the response_class for this view, with a template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
- class biodiversity.views.BiodiversityAssessmentView(**kwargs)
Bases:
biodiversity.views.BiodiversityMixin
,django.views.generic.edit.FormView
View for biodiversity assessments
- form_class
alias of
biodiversity.forms.BiodiversityQuestionsForm
- form_invalid(form)
If the form is invalid, render the invalid form.
- form_valid(form)
Save the form data, send back the assessment score
- get_context_data(**kwargs)
overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field
we only use this form on GET because the POST is managed by the ProductSaveAsView
- Returns
dictionary of keyword arguements
- get_form_kwargs()
Return the keyword arguments for instantiating the form.
- get_success_url()
Return the URL to redirect to after processing a valid form.
- model
- class biodiversity.views.BiodiversityDownloadExcel(**kwargs)
Bases:
biodiversity.views.BiodiversityMixin
,django.views.generic.detail.DetailView
- build_response(wb)
Return an HttpResponse with the content of the workbook.
- model
alias of
biodiversity.models.Assessment
- class biodiversity.views.BiodiversityDownloadPDF(**kwargs)
Bases:
biodiversity.views.BiodiversityMixin
,django.views.generic.base.View
- class biodiversity.views.BiodiversityGeneralView(**kwargs)
Bases:
biodiversity.views.BiodiversityMixin
,django.views.generic.edit.CreateView
,django.views.generic.edit.UpdateView
- form_class
alias of
biodiversity.forms.BiodiversityForm
- get_context_data(**kwargs)
overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field
we only use this form on GET because the POST is managed by the ProductSaveAsView
- Returns
dictionary of keyword arguements
- get_form_kwargs()
Return the keyword arguments for instantiating the form.
- get_object(queryset=None)
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- model
alias of
biodiversity.models.Assessment
- class biodiversity.views.BiodiversityMixin
Bases:
farm.views.FarmMixin
,farm.views.ProductCreationMixin
- model
alias of
biodiversity.models.Assessment
- class biodiversity.views.BiodiversityResource(**kwargs)
Bases:
biodiversity.views.BiodiversityMixin
,django.views.generic.detail.DetailView
- class biodiversity.views.BiodiversityResultsView(**kwargs)
Bases:
biodiversity.views.BiodiversityMixin
,django.views.generic.base.TemplateView
- get_context_data(**kwargs)
overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field
we only use this form on GET because the POST is managed by the ProductSaveAsView
- Returns
dictionary of keyword arguements