Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update secretariat dashboard style #8140

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 9 additions & 7 deletions ietf/secr/announcement/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ def get_to_choices():
# ---------------------------------------------

class AnnounceForm(forms.ModelForm):
nomcom = forms.ModelChoiceField(queryset=Group.objects.filter(acronym__startswith='nomcom',type='nomcom',state='active'),required=False)
nomcom = forms.ModelChoiceField(queryset=Group.objects.filter(acronym__startswith='nomcom', type='nomcom', state='active'), required=False)
to_custom = MultiEmailField(required=False)

class Meta:
model = Message
fields = ('nomcom', 'to','to_custom','frm','cc','bcc','reply_to','subject','body')
fields = ('nomcom', 'to', 'to_custom', 'frm', 'cc', 'bcc', 'reply_to', 'subject', 'body')
labels = {'frm': 'From'}
help_texts = {'to': 'Select name OR select Other... and enter email below',
'cc': 'Use comma separated lists for emails (Cc, Bcc, Reply To)'}

def __init__(self, *args, **kwargs):
if 'hidden' in kwargs:
Expand All @@ -91,19 +94,18 @@ def __init__(self, *args, **kwargs):
person = user.person
super(AnnounceForm, self).__init__(*args, **kwargs)
self.fields['to'].widget = forms.Select(choices=get_to_choices())
self.fields['to'].help_text = 'Select name OR select Other... and enter email below'
self.fields['cc'].help_text = 'Use comma separated lists for emails (Cc, Bcc, Reply To)'
self.fields['frm'].widget = forms.Select(choices=get_from_choices(user))
self.fields['frm'].label = 'From'
self.fields['reply_to'].required = True
# nomcom field is defined declaratively so label and help_text must be set here
self.fields['nomcom'].label = 'NomCom message:'
self.fields['nomcom'].help_text = 'If this is a NomCom announcement specifiy which NomCom group here'
nomcom_roles = person.role_set.filter(group__in=self.fields['nomcom'].queryset,name='chair')
secr_roles = person.role_set.filter(group__acronym='secretariat',name='secr')
if nomcom_roles:
self.initial['nomcom'] = nomcom_roles[0].group.pk
if not nomcom_roles and not secr_roles:
self.fields['nomcom'].widget = forms.HiddenInput()

if self.hidden:
for key in list(self.fields.keys()):
self.fields[key].widget = forms.HiddenInput()
Expand Down Expand Up @@ -134,4 +136,4 @@ def save(self, *args, **kwargs):
if nomcom:
message.related_groups.add(nomcom)

return message
return message
63 changes: 28 additions & 35 deletions ietf/secr/announcement/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
from ietf.message.models import AnnouncementFrom
from ietf.utils.mail import outbox, empty_outbox

SECR_USER='secretary'
WG_USER=''
AD_USER=''
SECR_USER = 'secretary'
WG_USER = ''
AD_USER = ''


class SecrAnnouncementTestCase(TestCase):
def setUp(self):
Expand All @@ -29,17 +30,17 @@ def setUp(self):
ietf = Group.objects.get(acronym='ietf')
iab = Group.objects.get(acronym='iab')
secretariat = Group.objects.get(acronym='secretariat')
AnnouncementFrom.objects.create(name=secr,group=secretariat,address='IETF Secretariat <[email protected]>')
AnnouncementFrom.objects.create(name=chair,group=ietf,address='IETF Chair <[email protected]>')
AnnouncementFrom.objects.create(name=chair,group=iab,address='IAB Chair <[email protected]>')
AnnouncementFrom.objects.create(name=secr, group=secretariat, address='IETF Secretariat <[email protected]>')
AnnouncementFrom.objects.create(name=chair, group=ietf, address='IETF Chair <[email protected]>')
AnnouncementFrom.objects.create(name=chair, group=iab, address='IAB Chair <[email protected]>')

def test_main(self):
"Main Test"
url = reverse('ietf.secr.announcement.views.main')
self.client.login(username="secretary", password="secretary+password")
r = self.client.get(url)
self.assertEqual(r.status_code, 200)

def test_main_announce_from(self):
url = reverse('ietf.secr.announcement.views.main')

Expand All @@ -48,44 +49,36 @@ def test_main_announce_from(self):
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('#id_frm option')),4)
self.assertEqual(len(q('#id_frm option')), 4)

# IAB Chair
self.client.login(username="iab-chair", password="iab-chair+password")
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('#id_frm option')),1)
self.assertEqual(len(q('#id_frm option')), 1)
self.assertTrue('<[email protected]>' in q('#id_frm option').val())

# IETF Chair
self.client.login(username="ietf-chair", password="ietf-chair+password")
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('#id_frm option')),1)
self.assertEqual(len(q('#id_frm option')), 1)
self.assertTrue('<[email protected]>' in q('#id_frm option').val())


class UnauthorizedAnnouncementCase(TestCase):
def test_unauthorized(self):
"Unauthorized Test"
url = reverse('ietf.secr.announcement.views.main')
person = RoleFactory(name_id='chair',group__acronym='mars').person
self.client.login(username=person.user.username, password=person.user.username+"+password")
person = RoleFactory(name_id='chair', group__acronym='mars').person
self.client.login(username=person.user.username, password=person.user.username + "+password")
r = self.client.get(url)
self.assertEqual(r.status_code, 403)



class SubmitAnnouncementCase(TestCase):
def test_invalid_submit(self):
"Invalid Submit"
url = reverse('ietf.secr.announcement.views.main')
post_data = {'id_subject':''}
self.client.login(username="secretary", password="secretary+password")
r = self.client.post(url,post_data)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertTrue(len(q('form ul.errorlist')) > 0)

def test_valid_submit(self):
"Valid Submit"
nomcom_test_data()
Expand All @@ -94,20 +87,20 @@ def test_valid_submit(self):
confirm_url = reverse('ietf.secr.announcement.views.confirm')
nomcom = Group.objects.get(type='nomcom')
post_data = {'nomcom': nomcom.pk,
'to':'Other...',
'to_custom':'rcross@amsl.com',
'frm':'IETF Secretariat &lt;[email protected]&gt;',
'reply_to':'[email protected]',
'subject':'Test Subject',
'body':'This is a test.'}
'to': 'Other...',
'to_custom': 'phil@example.com',
'frm': 'IETF Secretariat &lt;[email protected]&gt;',
'reply_to': '[email protected]',
'subject': 'Test Subject',
'body': 'This is a test.'}
self.client.login(username="secretary", password="secretary+password")
response = self.client.post(url,post_data)
response = self.client.post(url, post_data)
self.assertContains(response, 'Confirm Announcement')
response = self.client.post(confirm_url,post_data,follow=True)
response = self.client.post(confirm_url, post_data,follow=True)
self.assertRedirects(response, url)
self.assertEqual(len(outbox),1)
self.assertEqual(outbox[0]['subject'],'Test Subject')
self.assertEqual(outbox[0]['to'],'<rcross@amsl.com>')
self.assertEqual(len(outbox), 1)
self.assertEqual(outbox[0]['subject'], 'Test Subject')
self.assertEqual(outbox[0]['to'], '<phil@example.com>')
message = Message.objects.filter(by__user__username='secretary').last()
self.assertEqual(message.subject,'Test Subject')
self.assertEqual(message.subject, 'Test Subject')
self.assertTrue(nomcom in message.related_groups.all())
16 changes: 6 additions & 10 deletions ietf/secr/announcement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main(request):
if not check_access(request.user):
permission_denied(request, 'Restricted to: Secretariat, IAD, or chair of IETF, IAB, RSOC, RSE, IAOC, ISOC, NomCom.')

form = AnnounceForm(request.POST or None,user=request.user)
form = AnnounceForm(request.POST or None, user=request.user)

if form.is_valid():
# recast as hidden form for next page of process
Expand All @@ -71,7 +71,8 @@ def main(request):
'form': form},
)

return render(request, 'announcement/main.html', { 'form': form} )
return render(request, 'announcement/index.html', {'form': form})


@login_required
@check_for_cancel('../')
Expand All @@ -83,21 +84,16 @@ def confirm(request):
if request.method == 'POST':
form = AnnounceForm(request.POST, user=request.user)
if request.method == 'POST':
message = form.save(user=request.user,commit=True)
extra = {'Reply-To': message.get('reply_to') }
message = form.save(user=request.user, commit=True)
extra = {'Reply-To': message.get('reply_to')}
send_mail_text(None,
message.to,
message.frm,
message.subject,
message.body,
cc=message.cc,
bcc=message.bcc,
extra=extra,
)
extra=extra)

messages.success(request, 'The announcement was sent.')
return redirect('ietf.secr.announcement.views.main')




33 changes: 13 additions & 20 deletions ietf/secr/templates/announcement/confirm.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
{% extends "base_site.html" %}
{# Copyright The IETF Trust 2024, All Rights Reserved #}
{% extends "base.html" %}
{% load static %}

{% load ietf_filters %}
{% load django_bootstrap5 %}
{% block title %}Announcement{% endblock %}

{% block extrahead %}{{ block.super }}
<script src="{% static 'secr/js/utils.js' %}"></script>
{% endblock %}

{% block breadcrumbs %}{{ block.super }}
&raquo; Announcement
{% endblock %}

{% block content %}
<h1>Announcement</h1>


<div class="module">
<h2>Confirm Announcement</h2>

<form action="{% url "ietf.secr.announcement.views.confirm" %}" method="post">{% csrf_token %}
<form action="{% url 'ietf.secr.announcement.views.confirm' %}" method="post">{% csrf_token %}

<pre id="announce-confirm">
To: {{ to }}
Expand All @@ -29,15 +24,13 @@ <h2>Confirm Announcement</h2>
{{ message.body }}
</pre>

{{ form }}
<div class="button-group">
<ul id="announcement-button-list">
<li><button type="submit" name="submit" value="Send">Send</button></li>
<li><button type="button" onclick="history.go(-1);return false">Back</button></li>
<li><button type="submit" name="submit" value="Cancel">Cancel</button></li>
</ul>
</div> <!-- button-group -->
{% bootstrap_form form %}

<div class="d-flex justify-content-around">
<button class="btn btn-primary" type="submit" name="submit" value="Send">Send</button>
<button class="btn btn-secondary" type="button" onclick="history.go(-1);return false">Back</button>
<button class="btn btn-danger" type="submit" name="submit" value="Cancel">Cancel</button>
</div>
</form>
</div> <!-- module -->

Expand Down
31 changes: 31 additions & 0 deletions ietf/secr/templates/announcement/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{# Copyright The IETF Trust 2024, All Rights Reserved #}
{% extends "base.html" %}
{% load static %}
{% load ietf_filters %}
{% load django_bootstrap5 %}
{% block title %}Announcement{% endblock %}
{% block content %}
<h1 class="announcement">Announcement</h1>
{% if form.non_field_errors %}<div class="my-3 alert alert-danger">{{ form.non_field_errors }}</div>{% endif %}

<form id="announcement-form" method="post">
{% csrf_token %}
{% bootstrap_field form.nomcom layout='horizontal' %}
{% bootstrap_field form.to layout='horizontal' %}
{% bootstrap_field form.to_custom layout='horizontal' %}
{% bootstrap_field form.frm layout='horizontal' %}
{% bootstrap_field form.cc layout='horizontal' %}
{% bootstrap_field form.bcc layout='horizontal' %}
{% bootstrap_field form.reply_to layout='horizontal' %}
{% bootstrap_field form.subject layout='horizontal' %}
{% bootstrap_field form.body layout='horizontal' %}

<button type="submit" class="btn btn-primary">Continue</button>
<a class="btn btn-secondary float-end"
href="{% url 'ietf.secr' %}">Cancel</a>
</form>

{% endblock %}
{% block js %}
<script src="{% static 'ietf/js/announcement.js' %}"></script>
{% endblock %}
36 changes: 0 additions & 36 deletions ietf/secr/templates/announcement/main.html

This file was deleted.

33 changes: 33 additions & 0 deletions ietf/secr/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{# Copyright The IETF Trust 2007, All Rights Reserved #}
{% extends "base.html" %}
{% load static %}
{% load ietf_filters %}
{% block title %}Secretariat Dashboard{% endblock %}
{% block content %}
<h1>Secretariat Dashboard</h1>
<div class="">
{% if user|has_role:"Secretariat" %}
<h2>IESG</h2>
<ul>
<li><a href="{% url 'ietf.secr.announcement.views.main' %}"><b>Announcement</b></a></li>
<li><a href="{% url 'ietf.secr.telechat.views.main' %}"><b>Telechat</b></a></li>
</ul>

<h2>IDs and WGs Process</h2>
<ul>
<li> <a href="{% url 'ietf.secr.rolodex.views.search' %}"><b>Rolodex</b></a></li>
</ul>

<h2>Meetings and Proceedings</h2>
<ul>
<li> <a href="{% url 'ietf.secr.sreq.views.main' %} "><b>Session Requests</b></a></li>
<li> <a href="{% url 'ietf.secr.meetings.views.main' %}"><b>Meeting Manager</b></a></li>
</ul>
{% else %}
<ul>
<li> <a href="{% url 'ietf.secr.sreq.views.main' %}"><b>Session Requests</b></a></li>
<li> <a href="{% url 'ietf.secr.announcement.views.main' %}"><b>Announcements</b></a></li>
</ul>
{% endif %}
</div>
{% endblock %}
Loading
Loading