Reference

Models

Django models for the jugemaj app.

jugemaj.models.CHOICES

alias of jugemaj.models.choix

class jugemaj.models.Candidate(*args, **kwargs)

An Election as Candidate as choices.

exception DoesNotExist
exception MultipleObjectsReturned
get_absolute_url()

Get the candidate’s Election URL.

majority_gauge()

Compute the majority gauge of this Candidate.

votes()

Get the list of the votes for this Candidate.

class jugemaj.models.Election(*args, **kwargs)

Main model for the jugemaj app.

exception DoesNotExist
exception MultipleObjectsReturned
get_absolute_url()

Reverse to the detail view for this instance.

results()

Get the sorted list of all Candidates for this Election.

class jugemaj.models.NamedCandidate(*args, **kwargs)

A common model to be used as a Candidate object.

exception DoesNotExist
exception MultipleObjectsReturned
class jugemaj.models.Vote(*args, **kwargs)

In an Election, each elector can give a rating to each Candidate.

exception DoesNotExist
exception MultipleObjectsReturned
get_absolute_url()

Let an elector a choice for a candidate.

jugemaj.models.sort_candidates(a, b)

Sort candidates a & b by their majority gauge.

  • α is the majority grade;
  • p the percentage of votes strictly above α;
  • q the percentage of votes strictly below α.

a > b ⇔ a_α > b_α || (a_α == b_α && (a_p > max(a_q, b_p, b_q) || b_q > max(a_p, a_q, b_p)))

(ref eq. 2, p.11 of the second article in README.md)

Forms

Django forms for the jugemaj app.

class jugemaj.forms.ElectionForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)

Form for the Election model.

class Meta

Declare the model and fields for this form.

model

alias of jugemaj.models.Election

Views

Views for django-jugemaj.

class jugemaj.views.CandidateCreateView(**kwargs)

View to create a Candidate to an Election.

form_valid(form)

Set the right Election for this Candidate.

get_success_url()

Redirect to the Election page.

model

alias of jugemaj.models.NamedCandidate

class jugemaj.views.ElectionCreateView(**kwargs)

View to create an Election.

form_class

alias of jugemaj.forms.ElectionForm

form_valid(form)

Set the election creator.

model

alias of jugemaj.models.Election

class jugemaj.views.ElectionDetailView(**kwargs)

View to detail an Election.

model

alias of jugemaj.models.Election

class jugemaj.views.ElectionListView(**kwargs)

View to list Elections.

model

alias of jugemaj.models.Election

class jugemaj.views.VoteView(**kwargs)

Views to let users vote for a Candidate.

model

alias of jugemaj.models.Vote

Template Tags and Filters

Templatetags for django-jugemaj.

jugemaj.templatetags.jugemaj.vote(candidate, request)

Get (or create) the vote object for a connected user and a candidate.