-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into position-postings
- Loading branch information
Showing
84 changed files
with
4,646 additions
and
1,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Django CI | ||
|
||
on: | ||
push: | ||
branches: [ master, dev ] | ||
pull_request: | ||
branches: [ master, dev ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: [3.6, 3.7] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements_debug.txt | ||
- name: Run Tests | ||
run: coverage run --omit="*/migrations/*","slack/api.py","inventory/*","src/*" manage.py test | ||
- name: Upload Coverage | ||
run: coveralls --service=github | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COVERALLS_FLAG_NAME: ${{ matrix.python-version }} | ||
COVERALLS_PARALLEL: true | ||
coveralls: | ||
name: Indicate completion to coveralls.io | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Finished | ||
run: | | ||
pip install --upgrade coveralls | ||
coveralls --service=github --finish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from django import forms | ||
|
||
from data.forms import FieldAccessForm, FieldAccessLevel | ||
from .models import OfficerImg, carrier_choices | ||
from .models import OfficerImg, carrier_choices, event_fields, UserPreferences | ||
from .ldap import get_student_id | ||
|
||
|
||
|
@@ -70,13 +70,12 @@ def __init__(self): | |
|
||
thisisme = FieldAccessLevel( | ||
lambda user, instance: (user == instance) and not user.locked, | ||
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox', | ||
'phone', 'class_year', 'nickname', 'carrier', 'pronouns') | ||
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox', 'phone', 'class_year', 'nickname', 'carrier', | ||
'pronouns') | ||
) | ||
hasperm = FieldAccessLevel( | ||
lambda user, instance: (user != instance) and user.has_perm('accounts.change_user', instance), | ||
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox', | ||
'phone', 'class_year') | ||
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox', 'phone', 'class_year') | ||
) | ||
edit_groups = FieldAccessLevel( | ||
lambda user, instance: user.has_perm('accounts.change_membership', instance), | ||
|
@@ -153,6 +152,158 @@ def save(self, commit=True): | |
return user | ||
|
||
|
||
class UserPreferencesForm(forms.ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
super(UserPreferencesForm, self).__init__(*args, **kwargs) | ||
if self.instance.rt_token not in [None, '']: | ||
self.Meta.layout.pop(-2) | ||
self.Meta.layout.insert(-1, ( | ||
"Text", "<button class=\"ui red small button\" type=\"submit\" name=\"submit\" " | ||
"value=\"rt-delete\">Delete Token</button>" | ||
)) | ||
else: | ||
self.Meta.layout.pop(-2) | ||
self.Meta.layout.insert(-1, ( | ||
"Text", "<a href=\"/support/connect/rt/\" class=\"ui green small button\">Connect Account</a>" | ||
)) | ||
|
||
if 'Inactive' in self.instance.user.group_str or 'Unclassified' in self.instance.user.group_str: | ||
self.Meta.layout[8] = ("Text", "</div><div class=\"title\"><i class=\"dropdown icon\"></i>" | ||
"Crew Chief Needed Notifications</div><div class=\"content\">" | ||
"<p class=\"ui help\">Receive an alert whenever the VP needs crew chiefs " | ||
"to run an event. These messages may be sent to either " | ||
"<em>[email protected]</em> or <em>[email protected]</em>. You may " | ||
"unsubscribe from these messages at any time through Outlook.</p>") | ||
self.Meta.layout[9] = ( | ||
"Text", "<a href=\"https://lnl.wpi.edu/legal/opt-out/\" class=\"ui blue basic button\">Opt out</a>" | ||
) | ||
else: | ||
self.Meta.layout[8] = ("Text", "</div><div class=\"title\"><i class=\"dropdown icon\"></i>" | ||
"Crew Chief Needed Notifications</div><div class=\"content\">" | ||
"<p class=\"ui help\">Receive an alert whenever the VP needs crew chiefs " | ||
"to run an event.</p>") | ||
self.Meta.layout[9] = ("Field", "cc_needed_subscriptions") | ||
self.fields['cc_needed_subscriptions'].initial = ['email', 'slack'] | ||
|
||
event_fields_required = [ | ||
('location', 'Location'), | ||
('datetime_setup_complete', 'Datetime setup complete'), | ||
('datetime_start', 'Datetime start'), | ||
('datetime_end', 'Datetime end') | ||
] | ||
|
||
event_fields_optional = [] | ||
for field in event_fields: | ||
if field not in event_fields_required: | ||
event_fields_optional.append(field) | ||
self.fields['event_edited_field_subscriptions'].choices = event_fields_optional | ||
|
||
self.fields['ignore_user_action'].widget.attrs['_style'] = 'toggle' | ||
self.fields['ignore_user_action'].widget.attrs['_help'] = True | ||
|
||
cc_add_subscriptions = forms.MultipleChoiceField( | ||
choices=(('email', 'Email'), ('slack', 'Slack Notification')), | ||
required=False, | ||
widget=forms.CheckboxSelectMultiple(attrs={ | ||
'_no_required': True, 'style': 'margin: 0.5% 0.5% 0 0; cursor: pointer', '_no_label': True | ||
}) | ||
) | ||
|
||
cc_report_reminders = forms.ChoiceField( | ||
choices=(('email', 'Email'), ('slack', 'Slack Notification'), ('all', 'Both')), | ||
widget=forms.RadioSelect(attrs={ | ||
'_no_required': True, 'style': 'margin: 0.5% 0.5% 0 0; cursor: pointer', '_no_label': True | ||
}) | ||
) | ||
|
||
cc_needed_subscriptions = forms.MultipleChoiceField( | ||
choices=(('email', 'Email'), ('slack', 'Slack Notification')), | ||
required=False, | ||
widget=forms.CheckboxSelectMultiple( | ||
attrs={'_no_required': True, 'style': 'margin: 0.5% 0.5% 0 0; cursor: pointer', '_no_label': True, 'disabled': True} | ||
) | ||
) | ||
|
||
event_edited_notification_methods = forms.ChoiceField( | ||
choices=(('email', 'Email'), ('slack', 'Slack Notification'), ('all', 'Both')), | ||
widget=forms.RadioSelect(attrs={ | ||
'_no_required': True, 'style': 'margin: 0.5% 0.5% 0 0; cursor: pointer', '_no_label': True | ||
}) | ||
) | ||
|
||
event_edited_field_subscriptions = forms.MultipleChoiceField( | ||
choices=event_fields, | ||
required=False, | ||
widget=forms.SelectMultiple(attrs={'_no_required': True, '_no_label': True, 'placeholder': 'Add more'}) | ||
) | ||
|
||
ignore_user_action = forms.BooleanField(label="Ignore my actions", required=False, | ||
help_text="Avoid sending me notifications for actions that I initiate") | ||
|
||
srv = forms.MultipleChoiceField( | ||
choices=(('email', 'Email'), ('slack', 'Slack Notification'), ('sms', 'SMS (Text Message)')), | ||
initial=['email', 'slack', 'sms'], | ||
required=False, | ||
widget=forms.CheckboxSelectMultiple( | ||
attrs={'_no_required': True, 'style': 'margin: 0.5% 0.5% 0 0', '_no_label': True, 'disabled': True} | ||
) | ||
) | ||
|
||
class Meta: | ||
model = UserPreferences | ||
fields = ('theme', 'cc_add_subscriptions', 'cc_report_reminders', 'event_edited_notification_methods', | ||
'event_edited_field_subscriptions', 'ignore_user_action') | ||
layout = [ | ||
("Text", "<div class=\"ui secondary segment\"><h4 class=\"ui dividing header\">Appearance</h4>"), | ||
("Field", "theme"), | ||
|
||
("Text", "</div><div class=\"ui secondary segment nobullet\"><h4 class=\"ui dividing header\">" | ||
"Communications</h4><div class=\"ui styled accordion\" style=\"width: 100%\"><div class=\"title\">" | ||
"<i class=\"dropdown icon\"></i>LNL News</div><div class=\"content\"><p class=\"ui help\">" | ||
"General club information, advertisements and meeting notices. This content will typically be " | ||
"sent to the <em>[email protected]</em> email alias. You may opt out of receiving these messages " | ||
"at any time through Outlook.</p>"), | ||
("Text", "<a href=\"https://lnl.wpi.edu/legal/opt-out/\" class=\"ui blue basic button\">Opt out</a>"), | ||
|
||
("Text", "</div><div class=\"title\"><i class=\"dropdown icon\"></i>Crew Chief Add Notifications</div>" | ||
"<div class=\"content\"><p class=\"ui help\">Receive a notification whenever you are added as a " | ||
"Crew Chief for a new event.</p>"), | ||
("Field", "cc_add_subscriptions"), | ||
|
||
("Text", "</div><div class=\"title\"><i class=\"dropdown icon\"></i>Crew Chief Report Reminders</div>" | ||
"<div class=\"content\"><p class=\"ui help\">Receive reminders for missing crew chief reports.</p>"), | ||
("Field", "cc_report_reminders"), | ||
|
||
("Text", "</div><div class=\"title\"><i class=\"dropdown icon\"></i>Crew Chief Needed Notifications</div>" | ||
"<div class=\"content\"><p class=\"ui help\">Receive an alert whenever the VP needs crew chiefs " | ||
"to run an event.</p>"), | ||
("Field", "cc_needed_subscriptions"), | ||
|
||
("Text", "</div><div class=\"title\"><i class=\"dropdown icon\"></i>Event Edit Notifications</div>" | ||
"<div class=\"content\"><p class=\"ui help\">Receive alerts whenever details for an event you are " | ||
"involved with have changed.</p>"), | ||
("Field", "event_edited_notification_methods"), | ||
("Text", "<br><hr style='border: 1px dashed gray'><br>" | ||
"<p class\"ui help\">Notify me of changes to any of the following fields:<br><br>" | ||
"<span class=\"ui label\">Location</span><span class=\"ui label\">Event Setup Time</span>" | ||
"<span class=\"ui label\">Event Start</span><span class=\"ui label\">Event End</span></p>"), | ||
("Field", "event_edited_field_subscriptions"), | ||
|
||
("Text", "</div><div class=\"title\"><i class=\"dropdown icon\"></i>Web Service Notifications</div>" | ||
"<div class=\"content\"><p class=\"ui help\">General account and system-wide notices. You may not " | ||
"unsubscribe from these messages.</p>"), | ||
("Field", "srv"), | ||
|
||
("Text", "</div></div><div class=\"ui segment\">"), | ||
("Field", "ignore_user_action"), | ||
|
||
("Text", "</div></div><div class=\"ui secondary segment\">" | ||
"<h4 class=\"ui dividing header\">Request Tracker</h4>"), | ||
("Text", "<a href=\"/support/connect/rt/\" class=\"ui green basic button\">Connect Account</a>"), | ||
("Text", "</div>") | ||
] | ||
|
||
|
||
class OfficerPhotoForm(forms.ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
self.helper = FormHelper() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Django 3.1.8 on 2021-11-21 19:19 | ||
|
||
from django.db import migrations, models | ||
import multiselectfield.db.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('accounts', '0006_user_pronouns'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='userpreferences', | ||
name='cc_add_subscriptions', | ||
field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('email', 'Email'), ('slack', 'Slack Notification')], default='email', max_length=11, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='userpreferences', | ||
name='cc_report_reminders', | ||
field=models.CharField(choices=[('email', 'Email'), ('slack', 'Slack Notification'), ('all', 'Both')], default='email', max_length=12), | ||
), | ||
migrations.AddField( | ||
model_name='userpreferences', | ||
name='event_edited_field_subscriptions', | ||
field=multiselectfield.db.fields.MultiSelectField(choices=[('event_name', 'Event name'), ('description', 'Description'), ('location', 'Location'), ('contact', 'Contact'), ('billing_org', 'Billing org'), ('datetime_setup_complete', 'Datetime setup complete'), ('datetime_start', 'Datetime start'), ('datetime_end', 'Datetime end'), ('internal_notes', 'Internal notes'), ('billed_in_bulk', 'Billed in bulk'), ('org', 'Client')], default=['location', 'datetime_setup_complete', 'datetime_start', 'datetime_end'], max_length=137), | ||
), | ||
migrations.AddField( | ||
model_name='userpreferences', | ||
name='event_edited_notification_methods', | ||
field=models.CharField(choices=[('email', 'Email'), ('slack', 'Slack Notification'), ('all', 'Both')], default='email', max_length=12), | ||
), | ||
migrations.AddField( | ||
model_name='userpreferences', | ||
name='ignore_user_action', | ||
field=models.BooleanField(default=False, help_text='Uncheck this to ignore notifications for actions triggered by the user'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.