Skip to content

Commit

Permalink
Merge pull request #593 from softwaresaved/dev
Browse files Browse the repository at this point in the history
v1.19.0
  • Loading branch information
jag1g13 authored Oct 2, 2020
2 parents ac90607 + f356cb3 commit f7647f5
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 97 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
omit =
# Omit Django migration files
*/migrations/*

# Omit tests themselves
*/test*.py
46 changes: 46 additions & 0 deletions .github/workflows/lowfat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: LowFAT

on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
django-version: [1.11]

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
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install django~=${{ matrix.django-version }}
- name: Test with Django test command
run: |
python manage.py test
- name: Test database migration and fixtures
run: |
python manage.py migrate
python manage.py loaddata fixtures/demo.json
- name: Lint with Pylint
run: |
python -m pylint lowfat
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ backups/
*.log.*

# Python runtime, setup and testing
.coverage
.mypy_cache/
__pycache__
env/
Expand Down
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

54 changes: 36 additions & 18 deletions lowfat/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime, date
import textwrap

from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.forms import (
BooleanField,
CharField,
Expand Down Expand Up @@ -46,7 +47,7 @@ def __init__(self, *args, **kwargs):
self.is_staff = kwargs.pop("is_staff", False)

# Set up Garlic attribute to persistent data
super(GarlicForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.attrs = {
'data_persist': "garlic",
Expand Down Expand Up @@ -84,7 +85,7 @@ class Meta:
required_css_class = 'form-field-required'

def __init__(self, *args, **kwargs):
super(ClaimantForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -200,7 +201,7 @@ class Meta:
required_css_class = 'form-field-required'

def __init__(self, *args, **kwargs):
super(FellowForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -348,7 +349,7 @@ def clean_end_date(self):
return self.cleaned_data['end_date']

def __init__(self, *args, **kwargs):
super(FundForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -561,7 +562,7 @@ def clean_end_date(self):
return self.cleaned_data['end_date']

def __init__(self, *args, **kwargs):
super(FundPublicForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -671,7 +672,7 @@ class Meta:
required_css_class = 'form-field-required'

def __init__(self, *args, **kwargs):
super(FundGDPRForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -718,7 +719,7 @@ class Meta:
email = CharField(widget=Textarea, required=False)

def __init__(self, *args, **kwargs):
super(FundReviewForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -754,7 +755,7 @@ class FundImportForm(Form):
csv = FileField()

def __init__(self, *args, **kwargs):
super(FundImportForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper = FormHelper()
self.helper.attrs = {
Expand Down Expand Up @@ -837,14 +838,23 @@ class Meta:
required_css_class = 'form-field-required'

def __init__(self, *args, **kwargs):
super(ExpenseForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
'',
'fund',
HTML("</p>If your funding request isn't on the drop down menu above please email <a href='mailto:{{ config.FELLOWS_MANAGEMENT_EMAIL }}'>us</a>."),
HTML("</p><a href='{{ terms_and_conditions_url }}'>Fellowship Programme's terms and conditions</a> applies to your request. Please follow the guidelines at <a href='{{ terms_and_conditions_url }}#how-to-apply-for-and-claim-expenses'>How to apply for, and claim, expenses</a> section of <a href='{{ terms_and_conditions_url }}'>Fellowship Programme's terms and conditions.</a></p>"),
HTML("<p>If your funding request isn't on the drop down menu above please email <a href='mailto:{{ config.FELLOWS_MANAGEMENT_EMAIL }}'>us</a>.</p>"),
HTML(textwrap.dedent("""\
<p>
Before submitting your expense claim:
<ol>
<li>Please follow the <a href='https://drive.google.com/file/d/1oddJAqzf7wIrzj7r3qPQ-ijoZzPcILQ9/view'>Guidelines for reimbursement of expenses from the Software Sustainability Institute</a>.</li>
<li>You MUST fill out and attach the <a href='https://drive.google.com/file/d/1muv__x8fhiaGw2hI81sytXTgFqnOsVGl/view'>University of Edinburgh Payment for Non-Staff/Student Expenses form</a> along with your receipts to your expense claim.</li>
<li>The <a href='{{ terms_and_conditions_url }}'>Fellowship Programme Terms and Conditions</a> and the <a href='https://drive.google.com/file/d/1wjCD2anwNGgDqee_2dm1C0moPrqxNbju/view'>University of Edinburgh Finance Expenses Policy</a> apply to your request.</li>
</ol>
</p>"""
)),
'claim',
PrependedText(
'amount_claimed',
Expand Down Expand Up @@ -900,7 +910,7 @@ class Meta:
required_css_class = 'form-field-required'

def __init__(self, *args, **kwargs):
super(ExpenseShortlistedForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -956,7 +966,7 @@ class Meta:
email = CharField(widget=Textarea, required=False)

def __init__(self, *args, **kwargs):
super(ExpenseReviewForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand Down Expand Up @@ -1032,7 +1042,7 @@ class Meta:


def __init__(self, *args, user=None, **kwargs):
super(BlogForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand All @@ -1041,7 +1051,14 @@ def __init__(self, *args, user=None, **kwargs):
'final',
'author' if self.is_staff else None,
'coauthor',
HTML("<p>We prefer to receive links to <a href='https://www.google.co.uk/docs/about/'>Google Docs</a> (tips <a href='/pages/guide/google-docs/'>here</a>), <a href='https://products.office.com/en-gb/office-365-home'>Microsoft Office 365 document</a> or any other online live collaborative document platform you like to use. Posts published somewhere already, e.g. your personal blog, are welcome as well.</p>"),
HTML(
"<p>For guidance on writing a blog post for the SSI website, please refer to the"
" <a href='https://software.ac.uk/resources/guides/guides-content-contributors'>Guides for content contributors.</a></p>"
"<p>We prefer to receive links to <a href='https://www.google.co.uk/docs/about/'>Google Docs</a>"
" (tips <a href='/pages/guide/google-docs/'>here</a>),"
" <a href='https://products.office.com/en-gb/office-365-home'>Microsoft Office 365 document</a>"
" or any other online live collaborative document platform you like to use."
" Posts published somewhere already, e.g. your personal blog, are welcome as well.</p>"),
'draft_url',
'success_reported',
'notes_from_author',
Expand Down Expand Up @@ -1083,7 +1100,7 @@ class Meta:
email = CharField(widget=Textarea, required=False)

def __init__(self, *args, **kwargs):
super(BlogReviewForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.helper.layout = Layout(
Fieldset(
Expand All @@ -1105,4 +1122,5 @@ def __init__(self, *args, **kwargs):
)
)

self.fields['reviewer'].queryset = User.objects.filter(is_staff=True)
self.fields['reviewer'].queryset = get_user_model().objects.filter(
is_staff=True)
9 changes: 6 additions & 3 deletions lowfat/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,18 @@ def review_notification(email_url, user_email, context, mail, copy_to_staffs=Fal
plain_text = html2text_fix(html)
mail.justification = plain_text

cc_addresses = [config.FELLOWS_MANAGEMENT_EMAIL]
if copy_to_gatekeeper:
cc_addresses.append(config.WEBSITE_GATEKEEPER)

# Email to claimant
msg = EmailMultiAlternatives(
flatemail.title,
plain_text,
mail.sender.email,
user_email,
cc=[config.WEBSITE_GATEKEEPER_EMAIL] if copy_to_gatekeeper else None,
bcc=ast.literal_eval(config.STAFFS_EMAIL) if copy_to_staffs else None,
reply_to=[config.FELLOWS_MANAGEMENT_EMAIL]
cc=cc_addresses,
bcc=ast.literal_eval(config.STAFFS_EMAIL) if copy_to_staffs else None
)
msg.attach_alternative(html, "text/html")
msg.send(fail_silently=False)
Expand Down
5 changes: 3 additions & 2 deletions lowfat/management/commands/load2018applications.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pandas as pd

from django.contrib.auth.models import User, BaseUserManager
from django.contrib.auth import get_user_model
from django.contrib.auth.models import BaseUserManager
from django.core.management.base import BaseCommand

from lowfat.models import Claimant
Expand Down Expand Up @@ -63,7 +64,7 @@ def handle(self, *args, **options):
success_list.append(index)

if received_offer:
new_user = User.objects.create_user(
new_user = get_user_model().objects.create_user(
username=applicant.slug,
email=applicant.email,
password=user_manager.make_random_password(),
Expand Down
7 changes: 4 additions & 3 deletions lowfat/management/commands/load2019applications.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pandas as pd

from django.contrib.auth.models import User, BaseUserManager
from django.contrib.auth import get_user_model
from django.contrib.auth.models import BaseUserManager
from django.core.management.base import BaseCommand
from django.db import IntegrityError

Expand Down Expand Up @@ -63,7 +64,7 @@ def handle(self, *args, **options):
success_list.append(index)

if received_offer:
new_user = User.objects.create_user(
new_user = get_user_model().objects.create_user(
username=applicant.slug,
email=applicant.email,
password=user_manager.make_random_password(),
Expand All @@ -85,7 +86,7 @@ def handle(self, *args, **options):
success_list.append(index)

if received_offer:
new_user = User.objects.create_user(
new_user = get_user_model().objects.create_user(
username=applicant.slug,
email=applicant.email,
password=user_manager.make_random_password(),
Expand Down
Loading

0 comments on commit f7647f5

Please sign in to comment.