GitHub PullRequestReviewCommentEvent at 2014-06-04 19:35:08
Repository: zamboni
Actor: ngokevin
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla/zamboni/pulls/comments/13405707","id":13405707,"diff_hunk":"@@ -0,0 +1,240 @@\n+from rest_framework import serializers, status, viewsets\n+from rest_framework.decorators import action\n+from rest_framework.exceptions import ParseError\n+from rest_framework.response import Response\n+\n+from django.db import IntegrityError, models\n+from django.utils.datastructures import MultiValueDictKeyError\n+\n+import amo.models\n+from amo.decorators import use_master\n+from amo.models import SlugField\n+from addons.models import clean_slug\n+\n+from mkt.api.authentication import (RestAnonymousAuthentication,\n+                                    RestOAuthAuthentication,\n+                                    RestSharedSecretAuthentication)\n+from mkt.api.base import CORSMixin, MarketplaceView, SlugOrIdMixin\n+from mkt.api.serializers import URLSerializerMixin\n+from mkt.webapps.models import Webapp\n+from mkt.webapps.tasks import index_webapps\n+\n+from collection.authorization import CuratorAuthorization\n+from .fields import FeedCollectionMembershipField\n+\n+\n+class BaseFeedCollectionMembership(amo.models.ModelBase):\n+    \"\"\"\n+\n+    \"\"\"\n+    app = models.ForeignKey(Webapp)\n+    order = models.SmallIntegerField(null=True)\n+    obj = None\n+\n+    class Meta:\n+        abstract = True\n+        ordering = ('order',)\n+        unique_together = ('obj', 'app',)\n+\n+\n+class BaseFeedCollection(amo.models.ModelBase):\n+    \"\"\"\n+    On the feed, there are a number of types of feed items that share a similar\n+    structure: a slug, one or more apps,\n+\n+    This is a base class for those feed items, including:\n+\n+    - Editorial Brands: `FeedBrand`\n+    - Collections: `FeedCollection`\n+    - Operator Shelves: `FeedOperatorShelf`\n+\n+    Subclasses must do  a few things:\n+\n+    - Define an M2M field named `_apps` with a custom through model that\n+      inherits from `BaseFeedCollectionMembership`.\n+    - Set the `membership_class` class property to the custom through model\n+      used by `_apps`.\n+    - Set the `membership_relation` class property to the name of the relation\n+      on the model.\n+    \"\"\"\n+    _apps = None\n+    slug = SlugField(blank=True, max_length=30,\n+                     help_text='Used in collection URLs.')\n+\n+    membership_class = None\n+    membership_relation = None\n+\n+    objects = amo.models.ManagerBase()\n+\n+    class Meta:\n+        abstract = True\n+        ordering = ('-id',)\n+\n+    def save(self, **kw):\n+        self.clean_slug()\n+        return super(BaseFeedCollection, self).save(**kw)\n+\n+    @use_master\n+    def clean_slug(self):\n+        clean_slug(self, 'slug')\n+\n+    def apps(self):\n+        \"\"\"\n+        Public apps on the collection, ordered by their position in the\n+        membership model.\n+\n+        Use this method everytime you want to display apps for a collection to\n+        an user.\n+        \"\"\"\n+        filters = {\n+            'disabled_by_user': False,\n+            'status': amo.STATUS_PUBLIC\n+        }\n+        return self._apps.filter(**filters).order_by(self.membership_relation)\n+\n+    def add_app(self, app, order=None):","path":"mkt/feed/base.py","position":95,"original_position":95,"commit_id":"5f2e548c7f7a358830666a929813adb1651d074a","original_commit_id":"5f2e548c7f7a358830666a929813adb1651d074a","user":{"login":"ngokevin","id":674727,"avatar_url":"https://avatars.githubusercontent.com/u/674727?","gravatar_id":"f1fa62935c8064826634fc93ce7aa4bb","url":"https://api.github.com/users/ngokevin","html_url":"https://github.com/ngokevin","followers_url":"https://api.github.com/users/ngokevin/followers","following_url":"https://api.github.com/users/ngokevin/following{/other_user}","gists_url":"https://api.github.com/users/ngokevin/gists{/gist_id}","starred_url":"https://api.github.com/users/ngokevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngokevin/subscriptions","organizations_url":"https://api.github.com/users/ngokevin/orgs","repos_url":"https://api.github.com/users/ngokevin/repos","events_url":"https://api.github.com/users/ngokevin/events{/privacy}","received_events_url":"https://api.github.com/users/ngokevin/received_events","type":"User","site_admin":false},"body":"TODO: replace add_app/remove_app/reorder with set_apps.","created_at":"2014-06-04T19:35:08Z","updated_at":"2014-06-04T19:35:08Z","html_url":"https://github.com/mozilla/zamboni/pull/2127#discussion_r13405707","pull_request_url":"https://api.github.com/repos/mozilla/zamboni/pulls/2127","_links":{"self":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/comments/13405707"},"html":{"href":"https://github.com/mozilla/zamboni/pull/2127#discussion_r13405707"},"pull_request":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/2127"}}}}