[widgets] Add food and trails widgets
This commit is contained in:
@ -14,8 +14,8 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
|
||||
from django.db.models import Count, Max, Q
|
||||
from django.db.models.query import QuerySet
|
||||
from rest_framework.authentication import TokenAuthentication
|
||||
from rest_framework.authtoken.views import ObtainAuthToken
|
||||
from rest_framework.authtoken.models import Token
|
||||
from rest_framework.authtoken.views import ObtainAuthToken
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
|
||||
|
||||
@ -1202,3 +1202,25 @@ class EmbeddableTopBooksWidget(BaseEmbeddableWidget):
|
||||
if not hasattr(item, "name") and hasattr(item, "title"):
|
||||
item.name = item.title
|
||||
return items
|
||||
|
||||
|
||||
class EmbeddableTopTrailsWidget(BaseEmbeddableWidget):
|
||||
media_type = "Trails"
|
||||
count_label = "visits"
|
||||
no_data_message = "No trails visited"
|
||||
|
||||
def get_items(self, user, start_date):
|
||||
from trails.models import Trail
|
||||
|
||||
return super().get_items(user, start_date, Trail)
|
||||
|
||||
|
||||
class EmbeddableTopFoodsWidget(BaseEmbeddableWidget):
|
||||
media_type = "Foods"
|
||||
count_label = "meals"
|
||||
no_data_message = "No foods logged"
|
||||
|
||||
def get_items(self, user, start_date):
|
||||
from foods.models import Food
|
||||
|
||||
return super().get_items(user, start_date, Food)
|
||||
|
||||
Reference in New Issue
Block a user