def testCacheDiffersByUrl(self): """ Проверяет, что кэш отличается для разных URL.""" p2 = Project.objects.create(name="another") Module.objects.create(project=p2, name="m3") self.url = reverse('test', args=(p2.pk,)) response = self.client.get(self.url) cache_key = TestView.get_cache_key(response._request) cache_content = self.redis.get(cache_key) self.assertNotEqual(cache_content, self.cache_content)
def setUp(self): self.project = Project.objects.create(name="project") self.m1 = Module.objects.create(project=self.project, name="m1") self.m2 = Module.objects.create(project=self.project, name="m2") self.url = self.get_url() self.response = self.client.get(self.url) self.redis = cacheops.conf.redis_client self.cache_key = TestView.get_cache_key(self.response._request) self.cache_content = self.redis.get(self.cache_key)
# -*- encoding: utf-8 -*- """Defines all urls conf.""" from django.conf.urls import patterns, url from django.contrib.auth.decorators import login_required from views import IndexView, ProfileView, TestView, SaveTestView, CourseView urlpatterns = patterns('', url(r'^$', login_required(IndexView.as_view()), name='dashboard'), url(r'^profile/$', login_required(ProfileView.as_view()), name='dashboard-profile'), url(r'^test/$', login_required(TestView.as_view()), name='dashboard-test'), url(r'^test/save/$', login_required(SaveTestView.as_view()), name='dashboard-save-test'), url(r'^(?P<course>\w{5,45})/$', login_required(CourseView.as_view()), name='dashboard-course'), )
TestCheckedAnswersView, TestCheckedAnswerView, ) urlpatterns = patterns('', url(r'^/?$', IndexView.as_view(), name='index'), url(r'^users/?$', UsersView.as_view(), name='users'), url(r'^users/(?P<id>-?[0-9]+)/?$', UserView.as_view(), name='user'), url(r'^users/me/?$', UserMeView.as_view(), name='user_me'), url(r'^groups/?$', GroupsView.as_view(), name='groups'), url(r'^groups/(?P<group_id>-?[0-9]+)/?$', GroupView.as_view(), name='group'), url(r'^groups/(?P<group_id>-?[0-9]+)/(?P<student_id>-?[0-9]+)/?$', GroupMemberView.as_view(), name='group_member'), url(r'^tests/?$', TestsView.as_view(), name='tests'), url(r'^tests/(?P<test_id>-?[0-9]+)/?$', TestView.as_view(), name='test'), url(r'^tests/(?P<test_id>-?[0-9]+)/groups/?$', TestGroupsView.as_view(), name='test_groups'), url(r'^tests/(?P<test_id>-?[0-9]+)/groups/(?P<group_id>-?[0-9]+)/?$', TestGroupView.as_view(), name='test_group'), url(r'^tests/(?P<test_id>-?[0-9]+)/students/?$', TestStudentsView.as_view(), name='test_students'), url(r'^tests/(?P<test_id>-?[0-9]+)/students/(?P<student_id>-?[0-9]+)/?$', TestStudentView.as_view(), name='test_student'), url(r'^tests/(?P<test_id>-?[0-9]+)/answers/?$', TestAnswersView.as_view(), name='test_answers'), url(r'^tests/(?P<test_id>-?[0-9]+)/answers/(?P<student_id>-?[0-9]+)/?$', TestAnswerView.as_view(), name='test_answer'), url(r'^tests/(?P<test_id>-?[0-9]+)/checked_answers/?$', TestCheckedAnswersView.as_view(), name='test_checked_answers'), url(r'^tests/(?P<test_id>-?[0-9]+)/checked_answers/(?P<answer_id>-?[0-9]+)/?$', TestCheckedAnswerView.as_view(), name='test_checked_answer') )
from django.core.urlresolvers import reverse from django.views.generic import ListView, DetailView, TemplateView, CreateView __author__ = 'derya' from django.conf.urls import patterns, url from django.template.defaultfilters import register from django.views.decorators.http import require_http_methods, require_POST, require_GET from django.views.decorators.cache import cache_page from views import Index, HauntedLocationSearch, HauntedLocationDetail, AboutUs, HowItWorks, TestView, HauntedEpisodeGuide from models import Newsletter, Comment urlpatterns = patterns('', url(r'^$', cache_page(60 * 1)(Index.as_view()), name="HauntedIndex"), url(r'^detail/(?P<slug>[-\w\d]+),(?P<pk>\d+)$', cache_page(60 * 1)(HauntedLocationDetail.as_view()), name='HauntedLocationDetail'), url(r'^about_us$',AboutUs.as_view(), name='AboutUs'), url(r'^how_it_works$',HowItWorks.as_view(), name='HowItWorks'), url(r'^test$',TestView.as_view(), name='test'), url(r'^episode_guide',cache_page(60 * 1)(HauntedEpisodeGuide.as_view()), name='HauntedEpisodeGuide'), #GET Form returns url(r'^search$',HauntedLocationSearch.as_view(), name='HauntedLocationSearch'), #POST Form returns url(r'^newsletter$',require_POST(CreateView.as_view(model=Newsletter, success_url="/website/", template_name="website/partial/_dummy.html")), name='NewsletterView' ), url(r'^comment$',CreateView.as_view(model=Comment, success_url="/website/",template_name="website/partial/_dummy.html"), name='CommentView' ), )
) urlpatterns = patterns( '', url(r'^/?$', IndexView.as_view(), name='index'), url(r'^users/?$', UsersView.as_view(), name='users'), url(r'^users/(?P<id>-?[0-9]+)/?$', UserView.as_view(), name='user'), url(r'^users/me/?$', UserMeView.as_view(), name='user_me'), url(r'^groups/?$', GroupsView.as_view(), name='groups'), url(r'^groups/(?P<group_id>-?[0-9]+)/?$', GroupView.as_view(), name='group'), url(r'^groups/(?P<group_id>-?[0-9]+)/(?P<student_id>-?[0-9]+)/?$', GroupMemberView.as_view(), name='group_member'), url(r'^tests/?$', TestsView.as_view(), name='tests'), url(r'^tests/(?P<test_id>-?[0-9]+)/?$', TestView.as_view(), name='test'), url(r'^tests/(?P<test_id>-?[0-9]+)/groups/?$', TestGroupsView.as_view(), name='test_groups'), url(r'^tests/(?P<test_id>-?[0-9]+)/groups/(?P<group_id>-?[0-9]+)/?$', TestGroupView.as_view(), name='test_group'), url(r'^tests/(?P<test_id>-?[0-9]+)/students/?$', TestStudentsView.as_view(), name='test_students'), url(r'^tests/(?P<test_id>-?[0-9]+)/students/(?P<student_id>-?[0-9]+)/?$', TestStudentView.as_view(), name='test_student'), url(r'^tests/(?P<test_id>-?[0-9]+)/answers/?$', TestAnswersView.as_view(), name='test_answers'),
#-*- coding:utf-8 -*- from django.conf.urls import patterns, include, url from views import EmailConstructorView, SavingImageAjax, SavingTinyMCEImage, SavingTemplatesAjax, LoadTemplateAjax, \ DeleteTemplateAjax, GenerateThumbnail, TestView, email_autocomplete from django.contrib.admin.views.decorators import staff_member_required urlpatterns = patterns('', url(r'^$', staff_member_required(EmailConstructorView.as_view()), name='create_email'), url(r'^test/$', staff_member_required(TestView.as_view()), name='test'), # сохранение загруженного изображения на сервере url(r'^send/$', 'email_constructor.views.send'), url(r'^save_img/$', SavingImageAjax.as_view(), name='save_img'), url(r'^save_tinymce_img/$', SavingTinyMCEImage.as_view(), name='save_tinymce_img'), # сохранение шаблона url(r'^save_template/$', SavingTemplatesAjax.as_view(), name='save_template'), # загрузка выбранного шаблона url(r'^load_template/$', LoadTemplateAjax.as_view(), name='load_template'), # удаление выбранного шаблона url(r'^delete_template/$', DeleteTemplateAjax.as_view(), name='delete_template'), # генерирование эскиза для видео url(r'^generate_thumbnail/$', GenerateThumbnail.as_view(), name='generate_thumbnail'), # запоминание ранее введенных электронок url(r'^email_autocomplete/$', email_autocomplete, name='email_autocomplete') )
__author__="alfonso" __date__ ="$22-feb-2016 $" from django.conf.urls import url from views import TestView from django.views.decorators.csrf import csrf_exempt urlpatterns = ( url(r'^$', csrf_exempt(TestView.as_view()), name='member'), url(r'^(?P<id>[0-9]+)/$', csrf_exempt(TestView.as_view()), name='member'), )
from django.conf.urls.defaults import patterns, url from django.contrib.auth.decorators import login_required from views import TestView urlpatterns = patterns('devilry.projects.dev.apps.test', url(r'^$', login_required(TestView.as_view())))
# a very robust .ini parser ;) --see sample_config.ini with open('config.ini') as f: for line in f.readlines(): line = line.replace(' ', '').replace('\t', '').strip() if not line or line.startswith('#'): continue cfg.update([tuple(line.split('='))]) # app.config['EXPLAIN_TEMPLATE_LOADING'] = True app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_DATABASE_URI'] = \ "mysql://{user!s}:{password!s}@{host!s}/{database!s}".format(**cfg) db = SQLAlchemy(app) admin = Admin(app, name="{}-admin".format(cfg['database']), index_view=AdminIndexView(name='Admin Home', url='/'), template_mode='bootstrap3') admin.add_view(TestView(Test, db.session)) admin.add_view(ColumnPropertiesView(ColumnProperty, db.session)) if __name__ == '__main__': try: port = int(sys.argv[1]) except (IndexError, ValueError): port = 5000 app.run(port=port, debug=True)
from django.conf.urls.defaults import patterns, url from django.contrib.auth.decorators import login_required from views import TestView urlpatterns = patterns("devilry.projects.dev.apps.test", url(r"^$", login_required(TestView.as_view())))