GitHub PullRequestReviewCommentEvent at 2014-02-05 17:51:12
Repository: corporate
Actor: Neamar
Payload: {"comment":{"url":"https://api.github.com/repos/Neamar/corporate/pulls/comments/9470235","id":9470235,"diff_hunk":"@@ -0,0 +1,68 @@\n+# -*- coding: utf-8 -*-\n+from django.db import models\n+from django.core.exceptions import ValidationError\n+from collections import Counter\n+\n+from engine.models import Order, Game\n+from engine_modules.corporation.models import Corporation\n+\n+\n+\t\n+class MDCVoteOrder(Order):\n+\t\"\"\"\n+\tOrder to vote for the party line of the MDC\n+\t\"\"\"\n+\n+\t# Enumerate the party lines and what they mean\n+\tMDC_PARTY_LINE_CHOICES = (('CPUB', u'Contrats publics'), \n+\t\t\t\t('CCIB', u'Contrôles ciblés'), \n+\t\t\t\t('DERE', u'Dérégulation'), \n+\t\t\t\t('DEVE', u'Développement urbain'), \n+\t\t\t\t('BANK', u'Garde-fous bancaires'), \n+\t\t\t\t('TRAN', u'Transparence'), \n+\t\t\t\t('NONE', u'Aucune'))\n+\n+\tweight = models.PositiveSmallIntegerField(default=1)\n+\tparty_line = models.CharField(max_length=4, \n+\t\t\t\tchoices=MDC_PARTY_LINE_CHOICES,\n+\t\t\t\tdefault = \"NONE\")\n+\n+\tdef resolve(self, vote_registry):\n+\n+\t\tif self.player in vote_registry.values():\n+\t\t\tself.weight = Counter(vote_registry.values())[self.player]+1\n+\t\t\tself.save()\n+\n+\t@classmethod\n+\tdef build_vote_registry(cls, game):\n+\t\t\"\"\"\n+\t\tBuild a registry of the top shareholders for each corporation that will be \n+\t\tused in resolve, but must be exported in order to be calculated only once\n+\t\t\"\"\"\n+\t\tvote_registry = {}\n+\t\tcorporations = game.corporation_set.all()\n+\t\tfor c in corporations:\n+\t\t\tshareholders  = (s.player for s in c.share_set.all())\n+\t\t\ttop_holders = Counter(shareholders).most_common(2)\n+\t\t\ttry:\n+\t\t\t\tif top_holders[0][1] != top_holders[1][1]:\n+\t\t\t\t\tvote_registry[c.base_corporation_slug] = top_holders[0][0]\n+\t\t\texcept(IndexError):\n+\t\t\t\tif len(top_holders) != 0:\n+\t\t\t\t\tvote_registry[c.base_corporation_slug] = top_holders[0][0]\n+\t\treturn vote_registry","path":"engine_modules/mdc/models.py","position":53,"original_position":53,"commit_id":"23404e0109165ecfa16a6f76ea34e0207c5ce000","original_commit_id":"23404e0109165ecfa16a6f76ea34e0207c5ce000","user":{"login":"Neamar","id":536844,"avatar_url":"https://gravatar.com/avatar/1bd44880100d5a4ce780441e4b54ddfe?d=https%3A%2F%2Fidenticons.github.com%2F14de7a24a4dd6804686069667dde27f5.png&r=x","gravatar_id":"1bd44880100d5a4ce780441e4b54ddfe","url":"https://api.github.com/users/Neamar","html_url":"https://github.com/Neamar","followers_url":"https://api.github.com/users/Neamar/followers","following_url":"https://api.github.com/users/Neamar/following{/other_user}","gists_url":"https://api.github.com/users/Neamar/gists{/gist_id}","starred_url":"https://api.github.com/users/Neamar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neamar/subscriptions","organizations_url":"https://api.github.com/users/Neamar/orgs","repos_url":"https://api.github.com/users/Neamar/repos","events_url":"https://api.github.com/users/Neamar/events{/privacy}","received_events_url":"https://api.github.com/users/Neamar/received_events","type":"User","site_admin":false},"body":"---\n- W191 indentation contains tabs\n","created_at":"2014-02-05T17:51:12Z","updated_at":"2014-02-05T17:51:12Z","html_url":"https://github.com/Neamar/corporate/pull/31#discussion_r9470235","pull_request_url":"https://api.github.com/repos/Neamar/corporate/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/comments/9470235"},"html":{"href":"https://github.com/Neamar/corporate/pull/31#discussion_r9470235"},"pull_request":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/31"}}}}