def contact(request): form = form_for_request(request, ContactForm) if request.method == 'POST' and form.is_valid(): data = form.data # Only send email if box2 is filled out and box1 is not. # box1 is display: none, so should never be filled out except by spam bots. if data.get('box2') and not data.get('box1'): send_contact_email(data.get('subject'), data.get('box2'), data.get('email')) logger.info("sent contact email: %s" % data) else: logger.info("suppressing invalid contact email: %s" % data) return HttpResponseRedirect(reverse('contact-success')) email_from = request.user.email if request.user.is_authenticated else "" form.initial = {"email": email_from} return render( request, 'contact.html', { "form": form, "email": settings.DEFAULT_FROM_EMAIL, 'page_image': 'img/og_image/contact.png', 'meta_description': 'Email us at %s or fill out this form. ' % settings.DEFAULT_FROM_EMAIL, })
def send_new_signup_email(request, user): token_url = reverse('verify-user', kwargs={'user_id':user.pk, 'activation_nonce': user.get_activation_nonce()}, scheme="https") send_mail( 'Caselaw Access Project: Verify your email address', "Please click here to verify your email address: \n\n%s \n\nIf you received this message in error, please ignore it." % token_url, settings.DEFAULT_FROM_EMAIL, [user.email], fail_silently=False, ) logger.info("sent new_signup email for %s" % user.email)
async def main(): queries = get_queries() logger.info('queries', queries=queries) domains = get_domains() logger.info('domains', domains=domains, ) results_for_domains = await make_actions(domains=domains, queries=queries) logger.info('results_for_domains', results_for_domains=results_for_domains) path_to_report = await make_report(results_for_domains=results_for_domains, queries=queries) logger.info('path_to_report', path_to_report=path_to_report, )
case_html = None if serialized_data['casebody']['status'] == 'ok': case_html = serialized_data['casebody']['data'] # link all captured cites case_html = link_to_cites(case_html, serialized_data['cites_to']) if settings.GEOLOCATION_FEATURE and request.META.get('HTTP_X_FORWARDED_FOR'): # Trust x-forwarded-for in this case because we don't mind being lied to, and would rather show accurate # results for users using honest proxies. ip = request.META['HTTP_X_FORWARDED_FOR'].split(',')[-1] try: location = geolocate(ip) location_str = location.country.name if location.subdivisions: location_str = "%s, %s" % (location.subdivisions.most_specific.name, location_str) logger.info(f"Someone from {location_str} read a case from {case.court.name}.") except Exception as e: logger.warning(f"Unable to geolocate {ip}: {e}") # set CSRF token for staff so they can make ajax requests if request.user.is_staff: get_token(request) formatted_name = db_case.name.replace(' v. ', ' <span class="case-name-v">v.</span> ') # find case in other dbs similar_cases = [] if resolved_case: similar_cases = group_by(resolved_case.get_similar(), lambda r: r.source) for group in similar_cases.values(): group.sort(reverse=True, key=lambda c: c.similarity)