Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_talk_voting_available_with_proposal(user_client):
get_default_conference()
create_talk_for_user(user=user_client.user)
url = reverse("talk_voting:talks")
response = user_client.get(url)
assert response.status_code == 200
assert template_used(response, "conference/talk_voting/voting.html")
def test_update_foreignkey(self):
"""Update foreign key"""
url = reverse('feedreader:update_item')
response = self.client.post(url,
{'identifier': 'feedreader-Feed-group-%s' % self.feed.id,
'data_value': self.group.id},
secure=True)
self.assertEqual(response.status_code,
200,
'Unexpected status code, got %s expected 200' %
(response.status_code))
# Update foreign key to None
response = self.client.post(url,
{'identifier': 'feedreader-Feed-group-%s' % self.feed.id,
'data_value': ''},
secure=True)
self.assertEqual(response.status_code,
200,
'Unexpected status code, got %s expected 200' %
def test_bad_format(self, mock_alert):
self.body = {"hello": "world"}
res = self.client.post(
reverse("webhook", urlconf="alert.urls"),
data=json.dumps({"hello": "world"}),
content_type="application/json",
**self.headers,
)
self.assertEqual(400, res.status_code)
self.assertFalse(mock_alert.called)
self.assertEqual(0, StatusUpdate.objects.count())
def test_register_201(self):
self.assertEqual(User.objects.count(), 0)
url = reverse('freeradius:rest_register', args=[self.default_org.slug])
r = self.client.post(url, {
'username': 'test@test.org',
'email': 'test@test.org',
'password1': 'password',
'password2': 'password'
})
self.assertEqual(r.status_code, 201)
self.assertIn('key', r.data)
self.assertEqual(User.objects.count(), 1)
user = User.objects.first()
self.assertIn((self.default_org.pk,), user.organizations_pk)
def test_prevent_removing_topic_from_agenda(self):
topic = Topic.objects.create(title="test_title_lwOCK32jZGFb37DpmoP(")
item_id = topic.agenda_item_id
response = self.client.delete(reverse("item-detail", args=[item_id]))
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
kwargs.update({'level': level})
elif space is not None:
kwargs.update({'space': space})
ctx.update({
'back_url': reverse('.'.join(request.resolver_match.url_name.split('.')[:-1]+['list']), kwargs=kwargs),
})
if request.method == 'POST':
if not new and request.POST.get('delete') == '1':
# Delete this mapitem!
if request.POST.get('delete_confirm') == '1':
obj.delete()
if model == Level:
if obj.on_top_of_id is not None:
return redirect(reverse('editor.levels.detail', kwargs={'pk': obj.on_top_of_id}))
return redirect(reverse('editor.index'))
elif model == Space:
return redirect(reverse('editor.spaces.list', kwargs={'level': obj.level.pk}))
return redirect(ctx['back_url'])
ctx['obj_title'] = obj.title
return render(request, 'editor/delete.html', ctx)
form = model.EditorForm(instance=model() if new else obj, data=request.POST, request=request)
if form.is_valid():
# Update/create objects
obj = form.save(commit=False)
if form.titles is not None:
obj.titles = {}
for language, title in form.titles.items():
if title:
def create_cwr(self, request, qs):
"""Batch action that redirects to the add view for
:class:`CWRExportAdmin` with selected works.
"""
url = reverse('admin:music_publisher_cwrexport_add')
work_ids = qs.values_list('id', flat=True)
view = CWRExportAdmin(CWRExport, admin.site).add_view(
request, url, work_ids=work_ids)
return view
last_30_end = yesterday_end
prev_30_start = last_30_start + timedelta(days=-30)
prev_30_end = last_30_end + timedelta(days=-30)
time_ranges = (
('yesterday', yesterday_start, yesterday_end),
('prev_day', prev_day_start, prev_day_end),
('last_7', last_7_start, last_7_end),
('prev_7', prev_7_start, prev_7_end),
('last_30', last_30_start, last_30_end),
('prev_30', prev_30_start, prev_30_end)
)
c = {
"url": _create_url(reverse('home'))
}
# Ordered list of collection sets
collection_sets = OrderedDict()
for collection_set in CollectionSet.objects.filter(group__in=user.groups.all()).filter(
collections__is_active=True).order_by('name'):
# Using a cache to avoid regenerating the data repeatedly.
if collection_set in collection_set_cache:
collections = collection_set_cache[collection_set]
else:
collections = OrderedDict()
for collection in Collection.objects.filter(collection_set=collection_set).filter(is_active=True).order_by(
'name'):
collection_info = {
"url": _create_url(reverse('collection_detail', args=(collection.id,)))
}
if collection.is_on:
def get_success_url(self):
tally_id = self.kwargs.get('tally_id', None)
form_id = self.kwargs.get('form_id', None)
return reverse('update-form',
kwargs={'tally_id': tally_id, 'form_id': form_id})
def _default_url_generator(urlname, request):
return reverse(urlname, args=[request.domain])