def get(self, request, *args, **kwargs): event_view = EventView() news_view = NewsView() signup_view = SignUpView() context = { 'upcoming_events_view': event_view.get(request).content, 'news_items_view': news_view.get(request).content, 'signup_view': signup_view.get(request).content, } return self.render_to_response(context)
from django.urls import path from events.views import EventList, EventDetail, EventView urlpatterns = [ path('add/', EventView.as_view(), name='event_add'), path('edit/<int:pk>', EventView.as_view(), name='event_edit'), path('list/', EventList.as_view(template_name='event_list.html'), name='event_list'), path('<slug:slug>', EventDetail.as_view(), name='event_detail'), ]
from django.contrib import admin from django.urls import path, include from rest_framework.urlpatterns import format_suffix_patterns from events.views import EventView urlpatterns = [ path('', EventView.as_view()), path('<int:id>/', EventView.as_view()), ] urlpatterns = format_suffix_patterns(urlpatterns)
from django.urls import path from events.views import EventView, EventIndexView, SignupFormView, UnsignupFormView, SignupChargeView, \ UnsignupConfirmView, DeleteCommentView urlpatterns = [ path('', EventIndexView.as_view(), name='event_index'), path('<slug:slug>', EventView.as_view(), name='event_home'), path('signup/confirm', SignupChargeView.as_view(), name='event_charge'), path('signup/<slug:slug>', SignupFormView.as_view(), name='event_signup'), path('unsignup/confirm', UnsignupConfirmView.as_view(), name='event_unsignup_confirm'), path('unsignup/<slug:slug>', UnsignupFormView.as_view(), name='event_unsignup'), path('api/comment/delete', DeleteCommentView.as_view(), name='delete_comment'), ]
SuggestPublicView.as_view(), name="suggest_event_old"), url(r'^company/(?P<slug>[^/]*)/suggest/thanks$', TemplateView.as_view(template_name='companies/suggest_thanks.html'), name="suggest_thanks_old"), url(r'^preview/(?P<p_id>\d*)$', PreviewView.as_view(), name="preview"), url(r'^preview/(?P<p_id>\d*)/step1$', PreviewView1.as_view(), name="preview_step1"), url(r'^preview/(?P<p_id>\d*)/step2$', PreviewView2.as_view(), name="preview_step2"), # tenant-based pages url(r'^$', CompanyView.as_view(), name="event_list"), url(r'^event/(?P<pk>\d+)$', EventView.as_view(), name="one_event"), url(r'^event/(?P<pk>\d+).json$', JSONEventView.as_view(), name="one_event_json"), url(r'^calendar$', TemplateView.as_view(template_name='companies/calendar.html'), name="event_calendar"), url(r'^events.json$', JSONEventsView.as_view(), name="calendar"), url(r'^feed/events.ics$', EventFeed(), name="calendar_ics"), url(r'^suggest$', SuggestPublicView.as_view(), name="suggest_event"), url(r'^suggested/edit/(?P<secret>.*)$', SuggestEditPublicView.as_view(), name="suggested_edit"), url(r'^suggest/thanks$', TemplateView.as_view(template_name='companies/suggest_thanks.html'), name="suggest_thanks"),
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 django.conf.urls.static import (settings, static) from django.contrib import admin from events.views import (EventView, AttendeeView) admin.site.site_header = 'Longship Events Admin' admin.site.site_title = 'Longship Events' admin.site.index_title = 'Events Administration' urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^event/(?P<slug>[-\w]+)/attend$', AttendeeView.as_view()), url(r'^event/(?P<slug>[-\w]+)/$', EventView.as_view()), ] if settings.DEBUG is True: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
EventsView, LocationView, LocationsView, EventInviteDownloadView, ) from events.feeds import Calendar slug = '(?P<slug>[-\\w\\d]+)' pk = '(?P<pk>[0-9]+)' date = '(?P<date>[0-9]{4}-?[0-9]{2}-?[0-9]{2})' urlpatterns = [ # location re_path(r'^location/{slug}/{pk}/$'.format(slug=slug, pk=pk), LocationView.as_view(), name='location'), re_path(r'^locations/$', LocationsView.as_view(), name='locations'), # event re_path(r'^{date}/{slug}/{pk}/$'.format(date=date, slug=slug, pk=pk), EventView.as_view(), name='event'), re_path(r'^invite/{pk}/$'.format(pk=pk), EventInviteDownloadView.as_view(), name='event-invite'), re_path(r'^$', EventsView.as_view(), name='events'), # calendar path('feed/ical/', Calendar(), name='calendar'), ]
from django.urls import path from events.views import EventListView, EventView, JoinView, CreateEventView urlpatterns = [ path('', EventListView.as_view(), name='event_list_view'), path('<int:pk>/', EventView.as_view(), name='event_view'), path('<int:event_id>/join/', JoinView.as_view(), name='join_view'), path('create/', CreateEventView.as_view(), name='create_event_view'), ]
from django.urls import path from events.views import EventCreateView, MyEventView, EventView, EventDeleteView, EventUpdateView app_name = 'events' urlpatterns = [ path('', EventView.as_view(), name="view_events"), path('my-events', MyEventView.as_view(), name="my_events"), path('create/', EventCreateView.as_view(), name="create_event"), path('delete/<int:pk>', EventDeleteView.as_view(), name="delete_event"), path('update/<int:pk>', EventUpdateView.as_view(), name="update_event"), ]
from django.conf.urls import include, url, patterns from django.contrib import admin from django.views.decorators.http import require_POST from django.contrib.auth.decorators import login_required from events.views import EventView, EventListView, EventRegisterView, AttendeesView, EventUnRegisterView, DayEventsView urlpatterns = [ url(r'^(?P<page>[0-9]+)/$', EventListView.as_view()), url(r'^(?P<pk>\d+)/(?P<slug>[^/]+?)/$', EventView.as_view(), name='event_details'), url(r'^(?P<pk>\d+)/(?P<slug>[^/]+?)/register/$', login_required(EventRegisterView.as_view()), name='event_register_view'), url(r'^(?P<pk>\d+)/(?P<slug>[^/]+?)/unregister/$', login_required(EventUnRegisterView.as_view()), name='event_unregister_view'), url(r'^(?P<pk>\d+)/(?P<slug>[^/]+?)/attendees/$', login_required(AttendeesView.as_view()), name='attendees_view'), url(r'^dayevents/(?P<year>[0-9]+)/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$', DayEventsView.as_view(), name='day_events'), ]
def test_view_event_view_not_authenticated(self): request = self.request_factory.get(reverse('events_view', kwargs={'pk': self.event1.id})) request.user = AnonymousUser() response = EventView.as_view()(request, *[], **{'pk': self.event1.id}) self.assertEqual(response.status_code, HTTP_REDIRECT) self.assertIn('login', response.url)
from django.conf.urls import url from django.views.generic import TemplateView from events.feed import EventFeed from events.views import PreviewView, PreviewView1, PreviewView2, CompaniesListView, CompanyView, SuggestPublicView, \ JSONEventsView, EventView, JSONEventView, SuggestEditPublicView urlpatterns = [ url(r'^company/(?P<tenant_slug>[^/]*)$', CompanyView.as_view(), name="company"), url(r'^companies$', CompaniesListView.as_view(), name="companies_list"), url(r'^company/(?P<slug>[^/]*)/suggest$', SuggestPublicView.as_view(), name="suggest_event_old"), url(r'^company/(?P<slug>[^/]*)/suggest/thanks$', TemplateView.as_view(template_name='companies/suggest_thanks.html'), name="suggest_thanks_old"), url(r'^preview/(?P<p_id>\d*)$', PreviewView.as_view(), name="preview"), url(r'^preview/(?P<p_id>\d*)/step1$', PreviewView1.as_view(), name="preview_step1"), url(r'^preview/(?P<p_id>\d*)/step2$', PreviewView2.as_view(), name="preview_step2"), # tenant-based pages url(r'^$', CompanyView.as_view(), name="event_list"), url(r'^event/(?P<pk>\d+)$', EventView.as_view(), name="one_event"), url(r'^event/(?P<pk>\d+).json$', JSONEventView.as_view(), name="one_event_json"), url(r'^calendar$', TemplateView.as_view(template_name='companies/calendar.html'), name="event_calendar"), url(r'^events.json$', JSONEventsView.as_view(), name="calendar"), url(r'^feed/events.ics$', EventFeed(), name="calendar_ics"), url(r'^suggest$', SuggestPublicView.as_view(), name="suggest_event"), url(r'^suggested/edit/(?P<secret>.*)$', SuggestEditPublicView.as_view(), name="suggested_edit"), url(r'^suggest/thanks$', TemplateView.as_view(template_name='companies/suggest_thanks.html'), name="suggest_thanks"), ]