Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Felipe Álvarez
committed
Oct 14, 2015
1 parent
60eb7ea
commit a472ada
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.core.management.base import BaseCommand | ||
from elections.models import Election | ||
from elections.bin import SecondRoundCreator | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Clones an election" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('election_slug', type=str) | ||
parser.add_argument('candidates_slug', nargs='+', type=str) | ||
|
||
def handle(self, *args, **options): | ||
election = Election.objects.get(slug=options['election_slug']) | ||
sc = SecondRoundCreator(election) | ||
for candidate_slug in options['candidates_slug']: | ||
candidate = election.candidates.get(id=candidate_slug) | ||
sc.pick_one(candidate) | ||
second_round = sc.get_second_round() | ||
self.stdout.write("Clone created with name %s and slug %s" % (second_round.name, second_round.slug)) | ||
self.stdout.write("The url for it is %s" % (second_round.get_absolute_url())) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters