Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Replace PublicManager by MapManager
Browse files Browse the repository at this point in the history
- old Map.public behaviour replaced by Map.objects.visible(self.request)
  • Loading branch information
plepe committed Jan 9, 2016
1 parent fffd53b commit 47dd0e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions leaflet_storage/managers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.contrib.gis.db import models
from django.db.models import Q

class MapManager(models.GeoManager):
def visible(self, request):
filter = Q(share_status=self.model.PUBLIC)

class PublicManager(models.GeoManager):

def get_queryset(self):
return super(PublicManager, self).get_queryset().filter(
share_status=self.model.PUBLIC)
return self.filter(filter)
5 changes: 2 additions & 3 deletions leaflet_storage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.core.files.base import File

from .fields import DictField
from .managers import PublicManager
from .managers import MapManager


class NamedModel(models.Model):
Expand Down Expand Up @@ -139,8 +139,7 @@ class Map(NamedModel):
share_status = models.SmallIntegerField(choices=SHARE_STATUS, default=PUBLIC, verbose_name=_("share status"))
settings = DictField(blank=True, null=True, verbose_name=_("settings"))

objects = models.GeoManager()
public = PublicManager()
objects = MapManager()

def get_absolute_url(self):
return reverse("map", kwargs={'slug': self.slug or "map", 'pk': self.pk})
Expand Down

0 comments on commit 47dd0e5

Please sign in to comment.