Skip to content

Commit

Permalink
Updated a few things to get Nadine ready for Django 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jsayles committed Dec 8, 2021
1 parent 449cc84 commit 8cef0bc
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 93 deletions.
5 changes: 1 addition & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ flake8 = "*"
iPython = "*"

[packages]
Django = "==3.2.10"
Django = "~=4.0"
Pillow = "~=8.3"
psycopg2 = "~=2.9"
django-localflavor = "~=3.1"
django-localflavor-us = "~=1.1"
django-taggit = "~=1.5"
django-taggit-templatetags2 = "~=1.6"
django-crontab = "~=0.7"
Expand All @@ -44,7 +42,6 @@ django-jsignature = "==0.10"
WeasyPrint = "==53.3"
html5lib = "==1.1"
suds-community = "~=1.0"
pytz = "*"
safety = "*"
asgiref = "*"
setuptools = "*"
44 changes: 7 additions & 37 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions arpwatch/arp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from datetime import datetime, time, date, timedelta

from pysnmp.entity.rfc3413.oneliner import cmdgen
from pytz.exceptions import AmbiguousTimeError

from django.conf import settings
from django.core.files.storage import default_storage
Expand Down Expand Up @@ -122,8 +121,6 @@ def import_all():
file_data = default_storage.open(full_path)
import_file(file_data, runtime)
log.success = True
except AmbiguousTimeError:
log_message("Caught AmbiguousTimeError. This must be daylight savings. Deleting file")
finally:
default_storage.delete(full_path)
log.save()
Expand Down
2 changes: 1 addition & 1 deletion comlink/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.utils.datastructures import MultiValueDict
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.urls import reverse

from email.utils import parseaddr
Expand Down
3 changes: 1 addition & 2 deletions comlink/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#######################################################################

# A Signal for when an email has been received
email_received = Signal(providing_args=["instance", "attachments"])
email_received = Signal()


#######################################################################
Expand Down Expand Up @@ -94,4 +94,3 @@ def router(sender, **kwargs):


# Copyright 2021 Office Nomads LLC (https://officenomads.com/) Licensed under the AGPL License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

4 changes: 0 additions & 4 deletions doors/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ verify_ssl = true

[packages]
cryptography = "*"
pytz = "*"
pycparser = "*"
requests = "*"

[requires]
python_version = "3.5"
8 changes: 0 additions & 8 deletions doors/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions doors/keymaster/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import time
import logging
import pytz
import traceback
from datetime import datetime, timedelta, date

Expand Down Expand Up @@ -215,4 +214,3 @@ def keymaster(request):


# Copyright 2021 Office Nomads LLC (https://officenomads.com/) Licensed under the AGPL License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

18 changes: 14 additions & 4 deletions nadine/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext as _

from localflavor.us.us_states import US_STATES
from localflavor.ca.ca_provinces import PROVINCE_CHOICES

from comlink.mailgun import MailgunAPI

from nadine.models.core import HowHeard, Industry, Neighborhood, URLType, GENDER_CHOICES
Expand All @@ -34,6 +31,19 @@
logger = logging.getLogger(__name__)


US_STATES = [
'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA',
'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME',
'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM',
'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX',
'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY',
]

CA_PROVINCES = [
'AB', 'BC', 'MB', 'NB', 'NL', 'NT', 'NS',
'NU', 'ON', 'PE', 'QC', 'SK', 'YT'
]

class DateRangeForm(forms.Form):
START_DATE_PARAM = 'start'
END_DATE_PARAM = 'end'
Expand Down Expand Up @@ -271,7 +281,7 @@ def get_state_choices():
if settings.COUNTRY == 'US':
return US_STATES
elif settings.COUNTRY == 'CA':
return PROVINCE_CHOICES
return CA_PROVINCES


class ProfileImageForm(forms.Form):
Expand Down
37 changes: 32 additions & 5 deletions nadine/management/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,47 @@
import random
import getpass
import socket
import zoneinfo

from datetime import datetime

from django.conf import settings
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import get_random_secret_key

from pytz import country_names, country_timezones, common_timezones

EXAMPLE_LOCAL_SETTINGS_FILE = "nadine/settings/local_settings.example.py"
LOCAL_SETTINGS_FILE = "nadine/settings/local_settings.py"
PROMPT = '> '

COUNTRIES = [
"AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR",
"AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE",
"BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO",
"BN", "BG", "BF", "BI", "CV", "KH", "CM", "CA", "KY", "CF", "TD",
"CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI",
"HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG",
"SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF",
"PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD",
"GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN",
"HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT",
"JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG",
"LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK",
"MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT",
"MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA",
"NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP",
"NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN",
"PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN",
"LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC",
"SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES",
"LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ",
"TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV",
"UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU", "VE", "VN",
"VG", "VI", "WF", "EH", "YE", "ZM", "ZW"
]


class Command(BaseCommand):
help = "System Setup"
requires_system_checks = False
Expand Down Expand Up @@ -109,18 +137,18 @@ def setup_timezone(self):
country = input(PROMPT).strip().upper()
if not country:
print("Country Codes:")
print(('\n'.join('{}: {}'.format(k, country_names[k]) for k in sorted(country_names))))
print(", ".join(COUNTRIES))
print()
self.local_settings.set('COUNTRY', country)

# Timezone
tz = ''
while tz not in common_timezones:
while tz not in zoneinfo.available_timezones():
print("What timezone? (blank: list available)")
tz = input(PROMPT).strip()
if not tz:
print("Available Timezones:")
print((', '.join(country_timezones[country])))
print((", ".join(zoneinfo.available_timezones())))
print()
self.local_settings.set('TIME_ZONE', tz)

Expand Down Expand Up @@ -330,4 +358,3 @@ def save(self, filename):


# Copyright 2021 Office Nomads LLC (https://officenomads.com/) Licensed under the AGPL License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

25 changes: 12 additions & 13 deletions nadine/models/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
# Signals for every Trigger Action
#######################################################################

sign_in = Signal(providing_args=["user"])
profile_save = Signal(providing_args=["user"])
file_upload = Signal(providing_args=["user"])
change_membership = Signal(providing_args=["user"])
new_membership = Signal(providing_args=["user"])
ending_membership = Signal(providing_args=["user"])
new_desk_membership = Signal(providing_args=["user"])
ending_desk_membership = Signal(providing_args=["user"])
new_key_membership = Signal(providing_args=["user"])
ending_key_membership = Signal(providing_args=["user"])
new_mail_membership = Signal(providing_args=["user"])
ending_mail_membership = Signal(providing_args=["user"])
sign_in = Signal()
profile_save = Signal()
file_upload = Signal()
change_membership = Signal()
new_membership = Signal()
ending_membership = Signal()
new_desk_membership = Signal()
ending_desk_membership = Signal()
new_key_membership = Signal()
ending_key_membership = Signal()
new_mail_membership = Signal()
ending_mail_membership = Signal()


#######################################################################
Expand Down Expand Up @@ -433,4 +433,3 @@ class Meta:


# Copyright 2021 Office Nomads LLC (https://officenomads.com/) Licensed under the AGPL License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

2 changes: 0 additions & 2 deletions nadine/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from django.db.models.signals import post_save
from django.conf import settings
from django.utils.encoding import smart_str
from django_localflavor_us.models import USStateField, PhoneNumberField
from django.utils.timezone import localtime, now
from django.core.exceptions import ObjectDoesNotExist
from django.urls import reverse
Expand Down Expand Up @@ -112,4 +111,3 @@ class Meta:


# Copyright 2021 Office Nomads LLC (https://officenomads.com/) Licensed under the AGPL License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

1 change: 0 additions & 1 deletion nadine/models/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from django.db.models import Sum
from django.conf import settings
from django.utils.encoding import smart_str
from django_localflavor_us.models import USStateField, PhoneNumberField
from django.utils.timezone import localtime, now
from django.core.exceptions import ObjectDoesNotExist
from django.urls import reverse
Expand Down
13 changes: 7 additions & 6 deletions nadine/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random, string
import logging
import hashlib
import pytz

from datetime import datetime, time, date, timedelta
from dateutil.relativedelta import relativedelta

Expand All @@ -13,9 +13,9 @@
from django.contrib import admin
from django.contrib.auth.models import User
from django.core.files.base import ContentFile
from django.core.validators import RegexValidator
from django.conf import settings
from django.utils.encoding import smart_str
from django_localflavor_us.models import USStateField, PhoneNumberField
from django.utils.timezone import localtime, now
from django.urls import reverse

Expand Down Expand Up @@ -268,8 +268,9 @@ class UserProfile(models.Model):

user = models.OneToOneField(settings.AUTH_USER_MODEL, blank=False, related_name="profile", on_delete=models.CASCADE)
usercode = models.CharField(max_length=32, unique=True, null=True)
phone = PhoneNumberField(blank=True, null=True)
phone2 = PhoneNumberField("Alternate Phone", blank=True, null=True)
phoneRegex = RegexValidator(regex = r"^\+?1?\d{8,15}$")
phone = models.CharField(validators=[phoneRegex], max_length=20, blank=True, null=True)
phone2 = models.CharField("Alternate Phone", validators=[phoneRegex], max_length=20, blank=True, null=True)
address1 = models.CharField(max_length=128, blank=True)
address2 = models.CharField(max_length=128, blank=True)
city = models.CharField(max_length=128, blank=True)
Expand Down Expand Up @@ -736,7 +737,8 @@ class EmergencyContact(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, blank=False, on_delete=models.CASCADE)
name = models.CharField(max_length=254, blank=True)
relationship = models.CharField(max_length=254, blank=True)
phone = PhoneNumberField(blank=True, null=True)
phoneRegex = RegexValidator(regex = r"^\+?1?\d{8,15}$")
phone = models.CharField(validators=[phoneRegex], max_length=20, blank=True, null=True)
email = models.EmailField(blank=True, null=True)
last_updated = models.DateTimeField(auto_now_add=True)

Expand Down Expand Up @@ -926,4 +928,3 @@ def emergency_callback_save_callback(sender, **kwargs):


# Copyright 2021 Office Nomads LLC (https://officenomads.com/) Licensed under the AGPL License, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

0 comments on commit 8cef0bc

Please sign in to comment.