def safety(request): dictionary = {} if request.method == 'POST': form = SafetyIssueCreationForm(request.user, data=request.POST) if form.is_valid(): issue = form.save() send_safety_email_notification(request, issue) create_safety_notification(issue) dictionary = { 'title': 'Concern received', 'heading': 'Your safety concern was sent to NanoFab staff and will be addressed promptly', } if form.cleaned_data['post_alert']: now = timezone.now() alert_title = "Alert: Cleanroom may not be safe for entry" alert_preface = f'On {format_datetime(now)} {issue.reporter.get_full_name()} reported the following issue:\n' alert_contents = (alert_preface + issue.concern) safety_alert = Alert(title=alert_title, contents=alert_contents, creator=issue.reporter, debut_time=now) safety_alert.save() send_alert_emails(safety_alert) dictionary = { 'title': 'Concern received', 'heading': 'Your safety concern was sent to NanoFab staff and will be addressed promptly. An alert has been posted, and all labmembers have been emailed.', } return render(request, 'acknowledgement.html', dictionary) tickets = SafetyIssue.objects.filter(resolved=False).order_by('-creation_time') if not request.user.is_staff: tickets = tickets.filter(visible=True) dictionary['tickets'] = tickets dictionary['safety_introduction'] = get_media_file_contents('safety_introduction.html') dictionary['notifications'] = get_notifications(request.user, SafetyIssue) return render(request, 'safety/safety.html', dictionary)
def view_recent_news(request): dictionary = { 'news': News.objects.filter(archived=False).order_by('-pinned', '-last_updated'), 'notifications': get_notifications(request.user, News), } return render(request, 'news/recent_news.html', dictionary)
def buddy_system(request): mark_requests_expired() buddy_requests = BuddyRequest.objects.filter(expired=False, deleted=False).order_by( "start", "end", "-creation_time") # extend buddy request to add whether or not the current user can reply for buddy_request in buddy_requests: buddy_request.user_reply_error = check_user_reply_error( buddy_request, request.user) dictionary = { "buddy_requests": buddy_requests, "areas": Area.objects.filter(buddy_system_allowed=True).count(), "buddy_board_disclaimer": get_customization("buddy_board_disclaimer"), "request_notifications": get_notifications(request.user, BuddyRequest), "reply_notifications": get_notifications(request.user, BuddyRequestMessage), } return render(request, "buddy_system/buddy_system.html", dictionary)
def safety(request): dictionary = {} if request.method == 'POST': form = SafetyIssueCreationForm(request.user, data=request.POST) if form.is_valid(): issue = form.save() send_safety_email_notification(request, issue) dictionary['title'] = 'Concern received' dictionary['heading'] = 'Your safety concern was sent to NanoFab staff and will be addressed promptly' create_safety_notification(issue) return render(request, 'acknowledgement.html', dictionary) tickets = SafetyIssue.objects.filter(resolved=False).order_by('-creation_time') if not request.user.is_staff: tickets = tickets.filter(visible=True) dictionary['tickets'] = tickets dictionary['safety_introduction'] = get_media_file_contents('safety_introduction.html') dictionary['notifications'] = get_notifications(request.user, SafetyIssue) return render(request, 'safety/safety.html', dictionary)
def view_recent_news(request): dictionary = { 'news': News.objects.filter(archived=False), 'notifications': get_notifications(request.user, News), } return render(request, 'news/recent_news.html', dictionary)