Пример #1
0
    def retrieve(self, request, **kwargs):
        request.last_url = request.path
        page = Page.objects.get(pk=kwargs['pk'])
        page_info = PageDetailSerializer(page, context={'request': request})

        qs = Post.objects.filter(page=page).annotate(
            average_rate=Avg('rates__rate')).order_by(
                F('average_rate').desc(nulls_first=True), '-create_date')

        queryset = SearchFilter().filter_queryset(request, qs, PostView())

        page = self.paginate_queryset(queryset)
        if page is not None:
            serializer = self.get_serializer(page, many=True)
            return Response(
                OrderedDict([
                    ('count', self.paginator.page.paginator.count),
                    ('next', self.paginator.get_next_link()),
                    ('previous', self.paginator.get_previous_link()),
                    ('category_info', page_info.data),
                    ('results', serializer.data),
                ]))

        serializer = self.get_serializer(queryset, many=True)
        return Response(
            OrderedDict([
                ('category_info', page_info.data),
                ('post', serializer.data),
            ]))
from django.urls import path

from post.views import PostView, CommentCreateView

urlpatterns = [
    path('', PostView.as_view()),
    path('/<int:post_id>/comments', CommentCreateView.as_view())
]
Пример #3
0
from django.urls import path, include, re_path

from post.views import PostView

urlpatterns = [
    path('<slug:category_slug>/<slug:post_slug>/',
         PostView.as_view(),
         name="post-detail")
]
Пример #4
0
from django.urls import path
from post.views import PostView, ReadView, CommentView

urlpatterns = [
    path('/write', PostView.as_view()),
    path('/read', ReadView.as_view()),
    path('/comment', CommentView.as_view()),
]
Пример #5
0
from django.urls import path
from post.views import PostView, CommentView

urlpatterns = [
    path('post', PostView.as_view()),
    path('comment', CommentView.as_view())
]
from django.urls import path
from post.views import PostView, GetView

urlpatterns = [
    path('/upload', PostView.as_view()),
    path('/show', GetView.as_view()),
]
Пример #7
0
user_patterns = patterns('',
  # Calendar for a user
  url(r'^year/(?P<year>[\d]{4})/?', AthleteCalendarYear.as_view(), name="user-calendar-year"),
  url(r'^month/(?P<year>[\d]{4})/(?P<month>\d{1,2})/export/?$', login_required(AthleteExportMonth.as_view()), name="export-month-user"),
  url(r'^month/(?P<year>[\d]{4})/(?P<month>[\d]{1,2})/?', AthleteCalendarMonth.as_view(), name="user-calendar-month"),
  url(r'^week/(?P<year>[\d]{4})/(?P<week>[\d]{1,2})/?', AthleteCalendarWeek.as_view(), name="user-calendar-week"),
  url(r'^day/(?P<year>[\d]{4})/(?P<month>[\d]{1,2})/(?P<day>[\d]{1,2})/?', AthleteCalendarDay.as_view(), name="user-calendar-day"),

  # Stats for a user
  url(r'^stats/?$', AthleteStats.as_view(), name='athlete-stats'),
  url(r'^stats/all/?$', AthleteStats.as_view(), name='athlete-stats-all', kwargs={'all': True}),
  url(r'^stats/(?P<year>\d{4})/?$', AthleteStats.as_view(), name='athlete-stats-year'),

  # View post
  url(r'^post/(?P<slug>[\w_]+)/?$', PostView.as_view(), name='post'),

  # View badges
  url(r'badges/?', UserBadgesView.as_view(), name='badges-user'),

  url(r'^/?', PublicProfile.as_view(), name="user-public-profile"),
)

urlpatterns = patterns('',
  # Preferences, old & new
  url(r'^profile/?$', RedirectView.as_view(url='/user/preferences', permanent=True)),
  url(r'^preferences/?$', login_required(Preferences.as_view()), name='user-preferences'),

  url(r'^login/?$', LoginUser.as_view(), name='login'),
  url(r'^my-profile/?$', login_required(OwnProfile.as_view()), name='user-own-profile'),
  url(r'^garmin/?$', login_required(GarminLogin.as_view()), name='user-garmin'),
Пример #8
0
"""blog URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url

from post.views import PostView, PostsView, CommentView, CommentsView

urlpatterns = [
    url(r'^$', PostsView.as_view()),
    url(r'^comment/(?P<comment_pk>\d+)/$', CommentView.as_view()),
    url(r'^(?P<post_pk>\d+)/comment/$', CommentsView.as_view()),
    url(r'^(?P<post_pk>\d+)/$', PostView.as_view()),
]
Пример #9
0
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from rest_framework import routers
from rest_framework_swagger.views import get_swagger_view
from core.views import UserView, RegisterView, AuthTokenView
from post.views import PostView

router = routers.DefaultRouter()
router.register(r'users', UserView)

schema_view = get_swagger_view(title='Test API Docs')

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^api-docs/', schema_view),
    url(r'^api-auth/',
        include('rest_framework.urls', namespace='rest_framework')),
    url(r'^auth/', AuthTokenView.as_view(), name='auth'),
    url(r'^registration/', RegisterView.as_view(), name='registration'),
    url(r'^posts/', PostView.as_view(), name='post')
]
Пример #10
0
from django.urls import path
from post.views import (
    LogView,
    PostView,
    list_post,
)

app_name = "post"

urlpatterns = [
    path("<int:post_id>", PostView.as_view(), name="get"),
    path("list", list_post, name="list"),
    path("logs", LogView.as_view(), name="logs"),
]
Пример #11
0
from django.urls import path
from post.views import PostView

urlpatterns = [
    path('', PostView.as_view({
        'get': 'list',
        'post': 'create'
    })),
    path(
        '<int:pk>',
        PostView.as_view({
            'get': 'retrieve',
            'put': 'update',
            'delete': 'destroy'
        }))
]
Пример #12
0
from post import views as post

from search import views as s

from django_private_chat import urls as django_private_chat_urls

from django.conf.urls import url

from chat import views as chat

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', v.registration, name='register'),
    #path('',v.registration,name='register1'),
    # path('home/',post.home,name='home'),
    path('home/', PostView.as_view(), name='post-create'),
    path('post/<int:pk>/', PostDetailView.as_view(), name="post-detail"),
    path('post/new/', PostCreateView.as_view(), name="post-form"),
    path('post/<int:pk>/update/', PostUpdateView.as_view(),
         name="post-update"),
    path('post/<int:pk>/delete/', PostDeleteView.as_view(),
         name="post-delete"),
    #path('profile/',pr.ProfileUpdateView,name='profile'),  # wrong way to import class this will genrate an error because we are importing class as a function
    path('', include("django.contrib.auth.urls")),
    path(
        'profile_update/', pr.ProfileUpdateView.as_view(), name='phome'
    ),  #always import class based view as it. other wise it will give error that one extra argument given
    path('profile/', pr.ProfileView.as_view(), name='prhome'),
    path('homefeed/', post.home, name='post'),
    # path('search/',s.search.as_view(),name='search'),
    path('search/', s.search, name='search'),
Пример #13
0
from django.urls import path

from post.views import PostView, delete_comment

urlpatterns = [

    path('post/<str:slug>', PostView.as_view(), name="post"),
    path('delete_comment/', delete_comment, name="delete_comment")
    #path('add/comment', AddComment.as_view(), name="add_comment")
]
Пример #14
0
from django.conf.urls import patterns, url
from post.views import PostIndexView, PostView


urlpatterns = patterns('',
	url(r'^$', PostIndexView.as_view()),
	url(r'^(?P<slug>[-\w]+)/$', PostView.as_view(), name='post_detail'),
	url(r'^tag/(?P<tag>[-\w]+)/$', 'post.views.tagpage', name='tag_detail'),

	
	
)
Пример #15
0
from django.urls import path

from post.views import PostsView, PostView, ToggleLikeView, UserPostsView, PostsFromFollowingView, OtherUserPostsView, \
    PostsFromFriendsView, PostsLikedView

urlpatterns = [
    path('', PostsView.as_view()),
    path('<int:pk>/', PostView.as_view()),
    path('user/me/', UserPostsView.as_view()),
    path('user/<int:pk>/', OtherUserPostsView.as_view()),
    path('toggle-like/<int:pk>/', ToggleLikeView.as_view()),
    path('following/', PostsFromFollowingView.as_view()),
    path('friends/', PostsFromFriendsView.as_view()),
    path('likes/', PostsLikedView.as_view()),
]