• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python event.create_or_update_event函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中web.processors.event.create_or_update_event函数的典型用法代码示例。如果您正苦于以下问题:Python create_or_update_event函数的具体用法?Python create_or_update_event怎么用?Python create_or_update_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_or_update_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: edit_event

def edit_event(request, event_id):
    event = get_event_by_id(event_id)
    user = request.user
    initial = get_initial_data(event)
    initial['user_email'] = request.user.email

    event_data = {}

    if request.method == 'POST':
        event_form = AddEventForm(data=request.POST, files=request.FILES)
    else:
        event_form = AddEventForm(initial=initial)

    existing_picture = event.picture

    if event_form.is_valid():
        # picture_check works with jasny bootstrap magix
        picture_check = request.POST.get('picture')
        picture = request.FILES.get('picture', None)
        event_data = event_form.cleaned_data
        event_data['creator'] = request.user

        # checking if user entered a different email than in her profile
        if user.email != event_data['user_email']:
            update_user_email(user.id, event_data['user_email'])
        event_data.pop('user_email')

        try:
            if picture:
                if picture.size > (256 * 1024):
                    raise ImageSizeTooLargeException('Image size too large.')
                event_data['picture'] = process_image(picture)
            elif picture_check == "nochange":
                event_data['picture'] = existing_picture
            else:
                del event_data['picture']

            create_or_update_event(event_id, **event_data)

            return HttpResponseRedirect(
                reverse(
                    'web.view_event',
                    kwargs={
                        'event_id': event.id,
                        'slug': event.slug}))

        except ImageSizeTooLargeException:
            messages.error(
                request, 'The image is just a bit too big for us (must be up to 256 kb). '
                'Please reduce your image size and try agin.')
        except UploadImageError as e:
            messages.error(request, e.message)

    return render_to_response(
        'pages/add_event.html', {
            'form': event_form,
            'address': event_data.get('location', None),
            'editing': True,
            'picture_url': event.picture,
        }, context_instance=RequestContext(request))
开发者ID:AmericanSundown,项目名称:coding-events,代码行数:60,代码来源:events.py


示例2: edit_event

def edit_event(request, event_id):
    event = get_event_by_id(event_id)
    user = request.user
    initial = get_initial_data(event)
    initial["user_email"] = request.user.email

    event_data = {}

    if request.method == "POST":
        event_form = AddEventForm(data=request.POST, files=request.FILES)
    else:
        event_form = AddEventForm(initial=initial)

    existing_picture = event.picture

    if event_form.is_valid():
        # picture_check works with jasny bootstrap magix
        picture_check = request.POST.get("picture")
        picture = request.FILES.get("picture", None)
        event_data = event_form.cleaned_data
        event_data["creator"] = request.user

        # checking if user entered a different email than in her profile
        if user.email != event_data["user_email"]:
            update_user_email(user.id, event_data["user_email"])
        event_data.pop("user_email")

        try:
            if picture:
                if picture.size > (256 * 1024):
                    raise ImageSizeTooLargeException("Image size too large.")
                event_data["picture"] = process_image(picture)
            elif picture_check == "nochange":
                event_data["picture"] = existing_picture
            else:
                del event_data["picture"]

            create_or_update_event(event_id, **event_data)

            return HttpResponseRedirect(reverse("web.view_event", kwargs={"event_id": event.id, "slug": event.slug}))

        except ImageSizeTooLargeException:
            messages.error(
                request,
                "The image is just a bit too big for us (must be up to 256 kb). "
                "Please reduce your image size and try agin.",
            )
        except UploadImageError as e:
            messages.error(request, e.message)

    return render_to_response(
        "pages/add_event.html",
        {
            "form": event_form,
            "address": event_data.get("location", None),
            "editing": True,
            "picture_url": event.picture,
        },
        context_instance=RequestContext(request),
    )
开发者ID:kyyberi,项目名称:coding-events,代码行数:60,代码来源:events.py


示例3: test_scoreboard_api

    def test_scoreboard_api(self, client, admin_user):
        event_data = {
            "start_date": datetime.datetime.now() -
            datetime.timedelta(
                days=1,
                hours=3),
            "end_date": datetime.datetime.now() +
            datetime.timedelta(
                days=3,
                hours=3),
            "organizer": "some organizer",
            "creator": admin_user,
            "title": "Event in SI",
            "pub_date": datetime.datetime.now(),
            "country": "SI",
            "geoposition": Geoposition(
                46.05528,
                14.51444),
            "location": "Ljubljana",
            "audience": [1],
            "theme": [1],
            "tags": [
                "tag1",
                "tag2"],
        }

        event = create_or_update_event(**event_data)
        event.status = 'APPROVED'
        event.save()

        event_data = {
            "start_date": datetime.datetime.now() - datetime.timedelta(days=1, hours=3),
            "end_date": datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
            "organizer": "other organizer",
            "creator": admin_user,
            "title": "Event in IS",
            "pub_date": datetime.datetime.now(),
            "country": "IS",
            "geoposition": Geoposition(64.13244, -21.85690),
            "location": "Reykjavík",
            "audience": [1],
            "theme": [1],
            "tags": ["tag1", "tag2"],
        }

        event = create_or_update_event(**event_data)
        event.status = 'APPROVED'
        event.save()

        response_json = client.get('/api/scoreboard/?format=json')
        response_data = json.loads(response_json.content)

        assert isinstance(response_data, list)
        assert len(response_data) > 1
        assert response_data[0]["country_name"] == "Iceland"
        assert response_data[1]["country_name"] == "Slovenia"
开发者ID:AmericanSundown,项目名称:coding-events,代码行数:56,代码来源:test_restapi.py


示例4: test_edit_event_with_all_fields

    def test_edit_event_with_all_fields(self):
        # First create a new event
        with open(local(__file__).dirname + '/../../static/img/team/alja.jpg') as fp:
            io = StringIO.StringIO()
            io.write(fp.read())
            uploaded_picture = InMemoryUploadedFile(
                io, None, "alja.jpg", "jpeg", io.len, None)
            uploaded_picture.seek(0)

        event_data = {
            "end_date": datetime.datetime.now(),
            "start_date": datetime.datetime.now(),
            "organizer": "some organizer",
            "creator": User.objects.filter(pk=1)[0],
            "title": "event title",
            "pub_date": datetime.datetime.now(),
            "country": "SI",
            "geoposition": Geoposition(46.05528, 14.51444),
            "location": "Ljubljana",
            "audience": [1],
            "theme": [1],
            "tags": ["tag1", "tag2"],
            "picture": uploaded_picture
        }

        test_event = create_or_update_event(**event_data)

        # Then edit it
        with open(local(__file__).dirname + '/../../static/img/team/ercchy.jpg') as fp:
            io = StringIO.StringIO()
            io.write(fp.read())
            uploaded_picture = InMemoryUploadedFile(
                io, None, "ercchy.jpg", "jpeg", io.len, None)
            uploaded_picture.seek(0)

        event_data = {
            "end_date": datetime.datetime.now(),
            "start_date": datetime.datetime.now(),
            "organizer": "another organiser",
            "creator": User.objects.filter(pk=1)[0],
            "title": "event title - edited",
            "pub_date": datetime.datetime.now(),
            "country": "SI",
            # "geoposition": Geoposition(46.05528,14.51444),
            "location": "Ljubljana",
            "audience": [1],
            "theme": [1],
            "tags": ["tag3", "tag4"],
            "picture": uploaded_picture
        }
        test_event = create_or_update_event(
            event_id=test_event.id, **event_data)
        assert "tag1" not in test_event.tags.names()

        assert 'event_picture/alja' not in test_event.picture
        assert 'event_picture/ercchy' in test_event.picture.path
开发者ID:AmericanSundown,项目名称:coding-events,代码行数:56,代码来源:test_events_processors.py


示例5: test_create_event_in_each_listed_country

def test_create_event_in_each_listed_country(admin_user, db):
    all_countries = list_countries()

    for country in all_countries[2:]:
        country_code = country[1]
        country_name = country[0]

        event_data = {
            "audience": [3],
            "theme": [1, 2],
            "contact_person": u"[email protected]",
            "country": country_code,
            "description": u"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\r\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\r\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\r\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\r\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\r\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
            "event_url": u"",
            "location": country_name,
            "organizer": u"RailsGirls " + country_name,
            "creator": admin_user,
            "start_date": datetime.datetime.now(),
            "end_date": datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
            "tags": [u"css", u"html", u"web"],
            "title": u"RailsGirls " + country_name,
        }

        test_event = create_or_update_event(event_id=None, **event_data)

        assert country_code == test_event.country.code

        test_event.delete()
开发者ID:naisnouk,项目名称:coding-events,代码行数:28,代码来源:test_events_processors.py


示例6: test_create_event_from_dict_with_all_fields

    def test_create_event_from_dict_with_all_fields(self):
        with open(local(__file__).dirname + "/../../static/img/team/alja.jpg") as fp:
            io = StringIO.StringIO()
            io.write(fp.read())
            uploaded_picture = InMemoryUploadedFile(io, None, "alja.jpg", "jpeg", io.len, None)
            uploaded_picture.seek(0)

        event_data = {
            "end_date": datetime.datetime.now(),
            "start_date": datetime.datetime.now(),
            "organizer": "some organizer",
            "creator": User.objects.filter(pk=1)[0],
            "title": "event title",
            "pub_date": datetime.datetime.now(),
            "country": "SI",
            "geoposition": Geoposition(46.05528, 14.51444),
            "location": "Ljubljana",
            "audience": [1],
            "theme": [1],
            "tags": ["tag1", "tag2"],
            "picture": uploaded_picture,
        }

        test_event = create_or_update_event(**event_data)
        self.assertEqual(2, test_event.pk)
        self.assertEqual("Ljubljana", test_event.location)
        self.assertEqual("46.05528", str(test_event.geoposition.latitude))
        self.assertIn("tag1", test_event.tags.names())
        self.assertIn("tag2", test_event.tags.names())

        assert "event_picture/alja" in test_event.picture.path
开发者ID:naisnouk,项目名称:coding-events,代码行数:31,代码来源:test_events_processors.py


示例7: add_event

def add_event(request):
	event_form = AddEventForm()

	if request.method == 'POST':
		event_form = AddEventForm(data=request.POST, files=request.FILES)

	if event_form.is_valid():
		picture = request.FILES.get('picture', None)
		event_data = {}
		try:
			if picture:
				if picture.size > (256 * 1024):
					raise ImageSizeTooLargeException('Image size too large.')

				event_data['picture'] = process_image(picture)

			event_data.update(event_form.cleaned_data)
			event_data['creator'] = request.user
			event = create_or_update_event(**event_data)

			t = loader.get_template('alerts/thank_you.html')
			c = Context({'event': event, })
			messages.info(request, t.render(c))

			return HttpResponseRedirect(reverse('web.view_event', args=[event.pk, event.slug]))

		except ImageSizeTooLargeException:
			messages.error(request, 'The image is just a bit too big for us. '
			                        'Please reduce your image size and try agin.')
		except UploadImageError as e:
			messages.error(request, e.message)

	return render_to_response("pages/add_event.html", {
		'form': event_form,
	}, context_instance=RequestContext(request))
开发者ID:FloorD,项目名称:coding-events,代码行数:35,代码来源:events.py


示例8: test_view_just_id

def test_view_just_id(admin_user, db, client):
    event_data = {
        'audience': [3],
        'theme': [1, 2],
        'contact_person': u'[email protected]',
        'country': u'SI',
        'description': u'Lorem ipsum dolor sit amet',
        'event_url': u'',
        'location': u'Ljubljana, Slovenia',
        'organizer': u'CodeCatz test',
        "creator": admin_user,
        'start_date': datetime.datetime.now(),
        'end_date': datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
        'tags': [u'css', u'html', u'web'],
        'title': u'Redirect Test',
    }

    test_event = create_or_update_event(event_id=None, **event_data)

    # Test without a slash in the end
    response = client.get('/view/1')
    assert response.status_code == 301

    # Test with a slash in the end
    response = client.get('/view/1/')
    assert response.status_code == 302
开发者ID:AmericanSundown,项目名称:coding-events,代码行数:26,代码来源:test_site.py


示例9: test_event_list_all

	def test_event_list_all(self, client, admin_user):
		event_data = {
			"start_date": datetime.datetime.now() - datetime.timedelta(days=1, hours=3),
			"end_date": datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
			"organizer": "some organizer",
			"creator": admin_user,
			"title": "Unique REST API Event",
			"pub_date": datetime.datetime.now(),
			"country": "SI",
			"geoposition": Geoposition(46.05528,14.51444),
			"location": "Ljubljana",
			"audience": [1],
			"theme": [1],
			"tags": ["tag1", "tag2"],
		}

		event = create_or_update_event(**event_data)
		event.status = 'APPROVED'
		event.save()

		response_json = client.get('/api/event/list/?format=json')
		response_data = json.loads(response_json.content)

		assert isinstance(response_data, list)
		assert event_data['title'] in response_json.content
开发者ID:Konviser,项目名称:coding-events,代码行数:25,代码来源:test_restapi.py


示例10: create_event

    def create_event(
            self,
            title="Event title",
            start_date=datetime.datetime.now() +
            datetime.timedelta(
                days=0,
                hours=3),
            end_date=datetime.datetime.now() +
            datetime.timedelta(
                days=1,
                hours=3),
        country_code="SI",
            status="PENDING"):

        event_data = {
            "end_date": start_date,
            "start_date": end_date,
            "organizer": "Test organizer",
            "creator": self.get_user(),
            "title": title,
            "pub_date": datetime.datetime.now(),
            "country": country_code,
            "geoposition": "46.05528,14.51444",
            "location": "Ljubljana",
            "audience": [1],
            "theme": [1],
            "status": status,
        }
        return create_or_update_event(**event_data)
开发者ID:AmericanSundown,项目名称:coding-events,代码行数:29,代码来源:test_events_processors.py


示例11: test_create_event_from_dictionary_with_missing_required_fields

	def test_create_event_from_dictionary_with_missing_required_fields(self):
		with self.assertRaises(IntegrityError):
			event_data = {
				"end_date": datetime.datetime.now(),
				"start_date": datetime.datetime.now(),
				"organizer": "some organizer"
			}
			test_event = create_or_update_event(**event_data)
开发者ID:FloorD,项目名称:coding-events,代码行数:8,代码来源:test_events_processors.py


示例12: edit_event

def edit_event(request, event_id):
	event = get_event_by_id(event_id)
	initial = get_initial_data(event)

	event_data = {}

	if request.method == 'POST':
		event_form = AddEventForm(data=request.POST, files=request.FILES)
	else:
		event_form = AddEventForm(initial=initial)

	if event_form.is_valid():
		picture = request.FILES.get('picture', None)
		event_data = event_form.cleaned_data

		event_data['creator'] = request.user

		try:
			if picture:
				if picture.size > (256 * 1024):
					raise ImageSizeTooLargeException('Image size too large.')

				event_data['picture'] = process_image(picture)
			else:
				del event_data['picture']

			create_or_update_event(event_id, **event_data)

			return HttpResponseRedirect(reverse('web.view_event',
			                                    kwargs={'event_id': event.id, 'slug': event.slug}))

		except ImageSizeTooLargeException:
			messages.error(request, 'The image is just a bit too big for us (must be up to 256 kb). '
			                        'Please reduce your image size and try agin.')
		except UploadImageError as e:
			messages.error(request, e.message)
		
	return render_to_response(
		'pages/add_event.html', {
			'form': event_form,
			'address': event_data.get('location', None),
			'editing': True,
			'picture_url': event.picture,
		}, context_instance=RequestContext(request))
开发者ID:FloorD,项目名称:coding-events,代码行数:44,代码来源:events.py


示例13: test_create_event_from_dictionary_with_all_required_fields

	def test_create_event_from_dictionary_with_all_required_fields(self):
		event_data = {
				"end_date": datetime.datetime.now(),
				"start_date": datetime.datetime.now(),
				"organizer": "some organizer",
				"creator": User.objects.filter(pk=1)[0],
				"title": "event title",
				"pub_date": datetime.datetime.now(),
		}
		test_event = create_or_update_event(**event_data)
		self.assertEqual(2, test_event.pk)
		self.assertEqual("event title", test_event.title)
开发者ID:FloorD,项目名称:coding-events,代码行数:12,代码来源:test_events_processors.py


示例14: test_scoreboard_links_and_results

def test_scoreboard_links_and_results(admin_user, db, client):

    test_country_name = "Slovenia"
    test_country_code = "SI"

    search_url = reverse("web.search_events") + "?country_code=%s&past=yes" % test_country_code

    event_data = {
        "audience": [3],
        "theme": [1, 2],
        "country": test_country_code,
        "description": u"Lorem ipsum dolor sit amet.",
        "location": test_country_name,
        "organizer": u"testko",
        "creator": admin_user,
        "start_date": datetime.datetime.now(),
        "end_date": datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
        "title": u"Test Approved Event",
        "status": "APPROVED",
    }

    test_approved_event = create_or_update_event(event_id=None, **event_data)

    for country in count_approved_events_for_country():
        if country["country_code"] == test_country_code:
            event_count = country["events"]

    response = client.get(reverse("web.scoreboard"))

    # We're expecting to see this bit of HTML code with the right
    # search URL and the right count for events
    expected_result = """
	<span class="country-name">%s</span><p> is participating with </p>
	<a href="%s">
	<span class="event-number">%s event
	""" % (
        test_country_name,
        search_url,
        event_count,
    )

    expected_result = expected_result.replace("\t", "").replace("\n", "")
    scoreboard_content = response.content.replace("\t", "").replace("\n", "")

    # The search URL shown on scoreboard also has to match search results
    search_response = client.get(search_url)
    expected_search_result = '<div class="search-counter">%s event' % event_count

    assert expected_result in scoreboard_content
    assert expected_search_result in search_response.content

    test_approved_event.delete()
开发者ID:michelesr,项目名称:coding-events,代码行数:52,代码来源:test_event_views.py


示例15: add_event

def add_event(request):
	event_form = AddEvent()
	if request.method =="POST":
		event_form = AddEvent(data=request.POST, files=request.FILES)
		if event_form.is_valid():
			event_data = {}
			event_data.update(event_form.cleaned_data)
			event = create_or_update_event(**event_data)
			return render_to_response(
					'pages/thankyou.html',
					{'title': event.title, 'event_id': event.id},
					context_instance=RequestContext(request))
	context = {"form": event_form}
	return render_to_response("pages/add_event.html", context, context_instance=RequestContext(request))
开发者ID:pijab,项目名称:coding-events,代码行数:14,代码来源:events.py


示例16: test_scoreboard_links_and_results

def test_scoreboard_links_and_results(admin_user, db, client):

	test_country_name = "Slovenia"
	test_country_code = "SI"

	search_url = (reverse('web.search_events') + 
				"?country_code=%s&amp;past=yes" % test_country_code)

	event_data = {
			'audience': [3],
			'theme': [1,2],
			'country': test_country_code,
			'description': u'Lorem ipsum dolor sit amet.',
			'location': test_country_name,
			'organizer': u'testko',
			"creator": admin_user,
			'start_date': datetime.datetime.now(),
			'end_date': datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
			'title': u'Test Approved Event',
			'status':"APPROVED",
	}

	test_approved_event = create_or_update_event(event_id=None, **event_data)

	for country in count_approved_events_for_country():
		if country['country_code'] == test_country_code:
			event_count = country['events']

	response = client.get(reverse('web.scoreboard'))

	# We're expecting to see this bit of HTML code with the right
	# search URL and the right count for events
	expected_result = '''
	<span class="country-name">%s</span><p> is participating with </p>
	<a href="%s">
	<span class="event-number">%s event
	''' % (test_country_name, search_url, event_count)

	expected_result = expected_result.replace('\t', '').replace('\n', '')
	scoreboard_content = response.content.replace('\t', '').replace('\n', '')

	# The search URL shown on scoreboard also has to match search results
	search_response = client.get(search_url)
	expected_search_result = '<div class="search-counter">%s event' % event_count

	assert expected_result in scoreboard_content
	assert expected_search_result in search_response.content

	test_approved_event.delete()
开发者ID:gandalfar,项目名称:coding-events,代码行数:49,代码来源:test_event_views.py


示例17: test_create_event_in_martinique_for_france

def test_create_event_in_martinique_for_france(admin_user, db):
	event_data = {
		'audience': [3],
		'theme': [1,2],
		'contact_person': u'[email protected]',
		'country': u'FR',
		'description': u'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\r\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\r\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\r\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\r\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\r\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
		'event_url': u'',
		'location': u'1011 Chemin rural No 8 Bis de Clemencin, Le Lamentin, Martinique',
		'organizer': u'RailsGirls Martinique',
		"creator": admin_user,
		'start_date': datetime.datetime.now(),
		'end_date': datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
		'tags': [u'css', u'html', u'web'],
		'title': u'RailsGirls Martinique',
	}

	test_event = create_or_update_event(event_id=None, **event_data)

	assert "FR" == test_event.country.code
开发者ID:gandalfar,项目名称:coding-events,代码行数:20,代码来源:test_events_processors.py


示例18: test_create_event_from_dict_with_all_fields

	def test_create_event_from_dict_with_all_fields(self):
		event_data = {
			"end_date": datetime.datetime.now(),
			"start_date": datetime.datetime.now(),
			"organizer": "some organizer",
			"creator": User.objects.filter(pk=1)[0],
			"title": "event title",
			"pub_date": datetime.datetime.now(),
			"country": "SI",
			"geoposition": Geoposition(46.05528,14.51444),
			"location": "Ljubljana",
			"audience": [1],
			"theme": [1],
			"tags": ["tag1", "tag2"]
		}
		test_event = create_or_update_event(**event_data)
		self.assertEqual(2, test_event.pk)
		self.assertEqual("Ljubljana", test_event.location)
		self.assertEqual("46.05528", str(test_event.geoposition.latitude))
		self.assertIn("tag1", test_event.tags.names())
		self.assertIn("tag2", test_event.tags.names())
开发者ID:FloorD,项目名称:coding-events,代码行数:21,代码来源:test_events_processors.py


示例19: add_event

def add_event(request):
    if request.method == "POST":
        event_form = AddEventForm(data=request.POST, files=request.FILES)

        if event_form.is_valid():
            picture = request.FILES.get("picture", None)
            event_data = {}
            try:
                if picture:
                    if picture.size > (256 * 1024):
                        raise ImageSizeTooLargeException("Image size too large.")

                    event_data["picture"] = process_image(picture)

                event_data.update(event_form.cleaned_data)
                event_data["creator"] = request.user

                # checking if user entered a different email than in her profile
                if request.user.email != event_data["user_email"]:
                    update_user_email(request.user.id, event_data["user_email"])
                event_data.pop("user_email")

                event = create_or_update_event(**event_data)

                t = loader.get_template("alerts/thank_you.html")
                c = Context({"event": event})
                messages.info(request, t.render(c))

                return HttpResponseRedirect(reverse("web.view_event", args=[event.pk, event.slug]))

            except ImageSizeTooLargeException:
                messages.error(
                    request, "The image is just a bit too big for us. " "Please reduce your image size and try agin."
                )
            except UploadImageError as e:
                messages.error(request, e.message)
    else:
        event_form = AddEventForm(initial={"user_email": request.user.email})

    return render_to_response("pages/add_event.html", {"form": event_form}, context_instance=RequestContext(request))
开发者ID:kyyberi,项目名称:coding-events,代码行数:40,代码来源:events.py


示例20: test_list_active_countries

def test_list_active_countries(admin_user, db):
    """
    Verifies that only the countries with event which date is gte
    2014 are returned from the list_active_countries() function
    """

    events = [
        {
            # this country should be returned
            # because event is APPROVED and after 2014
            'location': u'Ljubljana, Slovenia',
            'country': 'SI',
            'organizer': u'testko',
            "creator": admin_user,
            'start_date': datetime.datetime.now(),
            'end_date': datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
            'title': u'Test Approved Event',
            'status': "APPROVED",
        },
        {
            # this country should be returned
            # for the same reasons
            'location': u'Paris, France',
            'country': 'FR',
            'organizer': u'testko',
            "creator": admin_user,
            'start_date': datetime.datetime.now(),
            'end_date': datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
            'title': u'Test Pending Event',
            'status': "APPROVED",
        },
        {
            # the same country should be returned only once
            'location': u'Ljubljana, Slovenia',
            'country': 'SI',
            'organizer': u'testko',
            "creator": admin_user,
            'start_date': datetime.datetime.now(),
            'end_date': datetime.datetime.now() + datetime.timedelta(days=3, hours=3),
            'title': u'Test Pending Event',
            'status': "APPROVED",
        },
        {
            # this country shouldn't be returned
            # because event start_date is < 2014
            'location': u'Rome, Italy',
            'country': 'IT',
            'organizer': u'testko',
            "creator": admin_user,
            'start_date': datetime.datetime(2013, 1, 1, 12, 00),
            'end_date': datetime.datetime(2013, 1, 1, 12, 00) + datetime.timedelta(days=3, hours=3),
            'title': u'Test Approved Event in other country',
            'status': "APPROVED",
        }
    ]

    # insert the listed events
    for event_data in events:
        create_or_update_event(event_id=None, **event_data)

    # retrieve the active countries from db
    active_countries = list_active_countries()

    # there should be only two active countries
    assert len(active_countries) == 2

    # and should be those two
    assert ('Slovenia', 'SI') in active_countries
    assert ('France', 'FR') in active_countries

    # if listing works, results are tuples ('country_name', 'country_code')
    # country_code should be a string with 2 characters
    for country in active_countries:
        assert len(country[1]) == 2
开发者ID:AmericanSundown,项目名称:coding-events,代码行数:74,代码来源:test_events_processors.py



注:本文中的web.processors.event.create_or_update_event函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.ApprovedEventFactory类代码示例发布时间:2022-05-26
下一篇:
Python models.User类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap