Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'uptime',
'topmost_filenames',
'reason',
'app_notes',
'release_channel',
),
'_results_number': batch_size,
'_results_offset': 0,
}
api = SuperSearch()
# Do the first query. That'll give us the total and the first page's
# worth of crashes.
data = api.get(**params)
assert 'hits' in data
response = http.HttpResponse(content_type='text/csv')
out = six.StringIO()
writer = csv.writer(out, dialect=csv.excel, delimiter='\t')
writer.writerow([
smart_text(part) for part in GRAPHICS_REPORT_HEADER
])
pages = data['total'] // batch_size
# if there is a remainder, add one more page
if data['total'] % batch_size:
pages += 1
alias = {
'crash_id': 'uuid',
'os_name': 'platform',
'os_version': 'platform_version',
'date_processed': 'date',
def edit_job(request):
activate(request.user.extended.language)
if request.method != 'POST':
return HttpResponse('')
job_id = request.POST.get('job_id', 0)
try:
job = Job.objects.get(pk=int(job_id))
except ObjectDoesNotExist:
return HttpResponse('')
if not jobs.utils.JobAccess(request.user, job).can_edit():
return HttpResponse('')
version = int(request.POST.get('version', 0))
if version > 0:
job_version = job.versions.get(version=version)
else:
job_version = job.versions.order_by('-change_date')[0]
job_versions = []
for j in job.versions.order_by('-version'):
if j.version == job.version:
title = _("Current version")
else:
job_time = j.change_date.astimezone(pytz.timezone(request.user.extended.timezone))
title = '%s (%s): %s' % (job_time.strftime("%d.%m.%Y %H:%M:%S"), j.change_author.get_full_name(), j.comment)
def allowed_actions(request, slug):
survey = _get_survey_or_404(slug, request)
authenticated = request.user.is_authenticated()
response = HttpResponse(mimetype='application/json')
dump({"enter": _can_show_form(request, survey),
"view": survey.can_have_public_submissions(),
"open": survey.is_open,
"need_login": survey.require_login and not authenticated}, response)
return response
def post(self, request, *args, **kwargs):
self.object = self.get_object()
self.object.hidden_by.remove(self.request.user)
data = {
'success': True,
}
return http.HttpResponse(json.dumps(data), content_type='application/json')
def _finalize_response(self, response):
""" Convert the ``Response`` object into django's ``HttpResponse``
:return: django's ``HttpResponse``
"""
res = HttpResponse(content=response.content,
content_type=self._get_content_type())
# status_code is set separately to allow zero
res.status_code = response.code
return res
def ajaxstaffverificationdeleteimage(request, verification, image):
if not request.user.is_authenticated() or request.user.is_anonymous() or not request.user.is_staff:
raise PermissionDenied()
verification = get_object_or_404(models.VerificationRequest, pk=verification)
imageObject = verification.images.get(pk=image)
imageObject.image.delete()
imageObject.delete()
return HttpResponse('deleted')
def getFTPdirectories(request):
if request.GET.has_key('address') and request.GET.has_key('username') and request.GET.has_key('password'):
address = request.GET['address']
username = request.GET['username']
password = request.GET['password']
if request.GET.has_key('directory'):
directory = request.GET['directory']
else:
directory = '/'
return HttpResponse(simplejson.dumps(testftp.runFTP(address, directory, username=username, password=password)))
return HttpResponse('Improper request')
def post(self, request):
register_form = ZcForm(request.POST)
if register_form.is_valid():
#获取所有的注册的post数据
usernames = request.POST.get("username", "")
password = request.POST.get("password", "")
password2 = request.POST.get("confirm_password", "")
phone_number = request.POST.get("phone_number", "")
email = request.POST.get("email", "")
#来判断用户名,邮箱,手机号是否注册过, 以及用户名密码是否正确
if UserProFile.objects.filter(username=usernames):
return HttpResponse('{"messages":"cw", "cw":"用户名存在"}', content_type='application/json')
if UserProFile.objects.filter(mobile=phone_number):
return HttpResponse('{"messages":"cw", "cw":"手机号已经存在"}', content_type='application/json')
if UserProFile.objects.filter(email=email):
return HttpResponse('{"messages":"cw", "cw":"邮箱已经存在"}', content_type='application/json')
if password == password2:
new_user = UserProFile()
new_user.nick_name = usernames
new_user.password = make_password(password)
new_user.mobile = phone_number
new_user.email = email
new_user.is_jh = False
new_user.username = usernames
new_user.save()
#注册成功后给用户发送一个激活邮件
send_register_email(email, "register", new_user.nick_name)
#注册成功后给用户发送一个系统消息
messages = Messages()
messages.user_name = new_user.id
def traffic(self, request):
try:
days_count = int(request.GET.get('days', 30))
except ValueError:
days_count = 30
if days_count < 10:
days_step = 1
elif days_count < 60:
days_step = 2
else:
days_step = 30
days = [date.today() - timedelta(day) for day in xrange(0, days_count, days_step)]
days_qs = [(day, Request.objects.day(date=day)) for day in days]
return HttpResponse(simplejson.dumps(modules.graph(days_qs)), mimetype='text/javascript')
if tags:
q['tags'] = ','.join(tags)
q['tag_mode'] = tag_mode
if text:
q['text'] = text
query = q.urlencode()
scope = ["/flickr/?%s" % query]
proxies = settings.FLICKR_PROXIES \
if form.cleaned_data['proxied'] else None
cookie = generate_cookie_django(
scope, settings.FLICKR_SERVERS, proxies,
blaster=getattr(settings, 'FLICKR_BLASTER', None))
return HttpResponse(cookie, content_type='application/x-diamond-scope')
else:
form = FlickrForm()
return render(request, 'scopeserver/simple_form.html', {
'form': form,
})