ahand / mobileesp

MobileESP
Apache License 2.0
172 stars 77 forks source link

detectSailfish missing #4

Closed ghost closed 9 years ago

ghost commented 9 years ago

I'm trying to use mdetect.py to detect mobile devices it's throwing an error detectSailfish missing. Following the directions on http://stackoverflow.com/questions/9119594/detect-mobile-tablet-or-desktop-on-django

ahand commented 9 years ago

Howdy, Drifter.

There was an issue with 2 calls to detectSailfish where they weren't prefaced by "self." A fix was merged this morning. Please give it another try.

ghost commented 9 years ago

Thanks got the changes up just one problem with classes it's not changing the templates will appreciate if you can help shed some light on this.

class VenueList(JSONResponseMixin, MultipleObjectTemplateResponseMixin, BaseListView): model = Venue paginate_by = 20 context_object_name = 'venues' category = None slug_level = "" area = None

template_name = 'directory/venue_index.html'

def get_queryset(self):
    if self.request.is_mobile:
        qs = Venue.objects.filter(visible=True,).order_by('-hot', '-created')
        if self.kwargs.get('category', None):
            self.template_name = 'directory/venue_list.html'
            slugs = self.kwargs['category'].strip('/').split('/')
            self.category = get_object_or_404(Category, slug=slugs[-1])
            qs = qs.filter(categories__in=self.category.get_descendants(include_self=True))
        if self.kwargs.get('area', None):

            self.template_name = 'directory/venue_list.html'
            slugs = self.kwargs['area'].strip('/').split('/')
            self.area = get_object_or_404(Area, slug=slugs[-1])
            qs = qs.filter(area__in=self.area.get_descendants(include_self=True))
        if self.request.META.get('HTTP_ACCEPT', None) == 'application/json':
            qs = qs.filter(longitude__isnull=False, latitude__isnull=False).exclude(longitude=0, latitude=0).order_by('name')
        self.queryset = qs.distinct()
        if not request.is_mobile:
            self.template_name = 'mobile/mobile.html'
        return self.queryset