Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions ietf/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ class ApiV2PersonExportView(DetailView, JsonExportMixin):
model = Person

def err(self, code, text):
return HttpResponse(text, status=code, content_type='text/plain')
return HttpResponse(
text,
status=code,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)

def post(self, request):
querydict = request.POST.copy()
Expand Down Expand Up @@ -152,7 +156,11 @@ def post(self, request):
def api_new_meeting_registration_v2(request):
'''REST API to notify the datatracker about a new meeting registration'''
def _http_err(code, text):
return HttpResponse(text, status=code, content_type="text/plain")
return HttpResponse(
text,
status=code,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)

def _api_response(result):
return JsonResponse(data={"result": result})
Expand Down Expand Up @@ -192,7 +200,11 @@ def _api_response(result):

process_single_registration(reg_data, meeting)

return HttpResponse('Success', status=202, content_type='text/plain')
return HttpResponse(
'Success',
status=202,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)


def version(request):
Expand Down Expand Up @@ -511,7 +523,11 @@ def related_email_list(request, email):
to Datatracker, via Person object
"""
def _http_err(code, text):
return HttpResponse(text, status=code, content_type="text/plain")
return HttpResponse(
text,
status=code,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)

if request.method == "GET":
try:
Expand Down Expand Up @@ -637,7 +653,11 @@ def ingest_email_handler(request, test_mode=False):
"""

def _http_err(code, text):
return HttpResponse(text, status=code, content_type="text/plain")
return HttpResponse(
text,
status=code,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)

def _api_response(result):
return JsonResponse(data={"result": result})
Expand Down
12 changes: 10 additions & 2 deletions ietf/doc/views_ballot.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ def edit_position(request, name, ballot_id):
@csrf_exempt
def api_set_position(request):
def err(code, text):
return HttpResponse(text, status=code, content_type='text/plain')
return HttpResponse(
text,
status=code,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)
if request.method == 'POST':
ad = request.user.person
name = request.POST.get('doc')
Expand Down Expand Up @@ -290,7 +294,11 @@ def err(code, text):
addrs, frm, subject, body = build_position_email(ad, doc, pos)
send_mail_text(request, addrs.to, frm, subject, body, cc=addrs.cc)

return HttpResponse("Done", status=200, content_type='text/plain')
return HttpResponse(
"Done",
status=200,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)


def build_position_email(balloter, doc, pos):
Expand Down
27 changes: 21 additions & 6 deletions ietf/iesg/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def agenda_txt(request, date=None):
"date": data["date"],
"sections": sorted(data["sections"].items(), key=lambda x:[int(p) for p in x[0].split('.')]),
"domain": Site.objects.get_current().domain,
}, content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)
}, content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}")

@role_required('Area Director', 'Secretariat')
def agenda_moderator_package(request, date=None):
Expand Down Expand Up @@ -277,14 +277,23 @@ def leaf_section(num, section):
@role_required('Area Director', 'Secretariat')
def agenda_package(request, date=None):
data = agenda_data(date)
return render(request, "iesg/agenda_package.txt", {
return render(
request,
"iesg/agenda_package.txt",
{
"date": data["date"],
"sections": sorted(data["sections"].items()),
"roll_call": data["sections"]["1.1"]["text"],
"minutes": data["sections"]["1.3"]["text"],
"management_items": [(num, section) for num, section in data["sections"].items() if "6" < num < "7"],
"management_items": [
(num, section)
for num, section in data["sections"].items()
if "6" < num < "7"
],
"domain": Site.objects.get_current().domain,
}, content_type='text/plain')
},
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)


def agenda_documents_txt(request):
Expand Down Expand Up @@ -315,7 +324,10 @@ def agenda_documents_txt(request):
d.rev,
)
rows.append("\t".join(row))
return HttpResponse("\n".join(rows), content_type='text/plain')
return HttpResponse(
"\n".join(rows),
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)

class RescheduleForm(forms.Form):
telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False)
Expand Down Expand Up @@ -610,4 +622,7 @@ def telechat_agenda_content_manage(request):
@role_required("Secretariat", "IAB Chair", "Area Director")
def telechat_agenda_content_view(request, section):
content = get_object_or_404(TelechatAgendaContent, section__slug=section, section__used=True)
return HttpResponse(content=content.text, content_type="text/plain; charset=utf-8")
return HttpResponse(
content=content.text,
content_type=f"text/plain; charset={settings.DEFAULT_CHARSET}",
)
56 changes: 48 additions & 8 deletions ietf/meeting/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@


from django.contrib import admin
from django.db.models import Count

from ietf.meeting.models import (Attended, Meeting, Room, Session, TimeSlot, Constraint, Schedule,
SchedTimeSessAssignment, ResourceAssociation, FloorPlan, UrlResource,
SessionPresentation, ImportantDate, SlideSubmission, SchedulingEvent, BusinessConstraint,
ProceedingsMaterial, MeetingHost, Registration, RegistrationTicket)
ProceedingsMaterial, MeetingHost, Registration, RegistrationTicket,
AttendanceTypeName)


class UrlResourceAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -219,32 +221,70 @@ class MeetingFilter(admin.SimpleListFilter):
parameter_name = 'meeting_id'

def lookups(self, request, model_admin):
# Your queryset to limit choices
choices = Meeting.objects.filter(type='ietf').values_list('id', 'number')
# only include meetings with registration records
meetings = Meeting.objects.filter(type='ietf').annotate(reg_count=Count('registration')).filter(reg_count__gt=0).order_by('-date')
choices = meetings.values_list('id', 'number')
return choices

def queryset(self, request, queryset):
if self.value():
return queryset.filter(meeting__id=self.value())
return queryset

class AttendanceFilter(admin.SimpleListFilter):
title = 'Attendance Type'
parameter_name = 'attendance_type'

def lookups(self, request, model_admin):
choices = AttendanceTypeName.objects.all().values_list('slug', 'name')
return choices

def queryset(self, request, queryset):
if self.value():
return queryset.filter(tickets__attendance_type__slug=self.value()).distinct()
return queryset

class RegistrationTicketInline(admin.TabularInline):
model = RegistrationTicket

class RegistrationAdmin(admin.ModelAdmin):
model = Registration
# list_filter = [('meeting', Meeting.objects.filter(type='ietf')), ]
list_filter = [MeetingFilter, ]
list_display = ['meeting', 'first_name', 'last_name', 'affiliation', 'country_code', 'person', 'email', ]
search_fields = ['meeting__number', 'first_name', 'last_name', 'affiliation', 'country_code', 'email', ]
list_filter = [AttendanceFilter, MeetingFilter]
list_display = ['meeting', 'first_name', 'last_name', 'display_attendance', 'affiliation', 'country_code', 'email', ]
search_fields = ['first_name', 'last_name', 'affiliation', 'country_code', 'email', ]
raw_id_fields = ['person']
inlines = [RegistrationTicketInline, ]
ordering = ['-meeting__date', 'last_name']

def display_attendance(self, instance):
'''Only display the most significant ticket in the list.
To see all the tickets inspect the individual instance
'''
if instance.tickets.filter(attendance_type__slug='onsite').exists():
return 'onsite'
elif instance.tickets.filter(attendance_type__slug='remote').exists():
return 'remote'
elif instance.tickets.filter(attendance_type__slug='hackathon_onsite').exists():
return 'hackathon onsite'
elif instance.tickets.filter(attendance_type__slug='hackathon_remote').exists():
return 'hackathon remote'
display_attendance.short_description = "Attendance" # type: ignore # https://github.com/python/mypy/issues/2087

admin.site.register(Registration, RegistrationAdmin)

class RegistrationTicketAdmin(admin.ModelAdmin):
model = RegistrationTicket
list_filter = ['attendance_type', ]
list_display = ['registration', 'attendance_type', 'ticket_type']
# not available until Django 5.2, the name of a related field, using the __ notation
# list_display = ['registration__meeting', 'registration', 'attendance_type', 'ticket_type', 'registration__email']
# list_select_related = ('registration',)
list_display = ['registration', 'attendance_type', 'ticket_type', 'display_meeting']
search_fields = ['registration__first_name', 'registration__last_name', 'registration__email']
raw_id_fields = ['registration']
ordering = ['-registration__meeting__date', 'registration__last_name']

def display_meeting(self, instance):
return instance.registration.meeting.number
display_meeting.short_description = "Meeting" # type: ignore # https://github.com/python/mypy/issues/2087

admin.site.register(RegistrationTicket, RegistrationTicketAdmin)
Loading
Loading