From c3934e09bd4c2d3fff4d7b4c10a9f06b8647c502 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sat, 8 Feb 2020 14:07:33 +0000 Subject: [PATCH] Server starts... Various things are broken, but it runs! --- PyRIGS/settings.py | 7 +++- RIGS/migrations/0036_auto_20200208_1342.py | 37 ++++++++++++++++++ RIGS/models.py | 39 +------------------ RIGS/urls.py | 4 +- ...8_1451_squashed_0021_auto_20190105_1156.py | 4 +- assets/migrations/0010_auto_20200208_1342.py | 21 ++++++++++ assets/models.py | 13 ++----- templates/base.html | 2 +- 8 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 RIGS/migrations/0036_auto_20200208_1342.py create mode 100644 assets/migrations/0010_auto_20200208_1342.py diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 5877ad74..7813e1be 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -44,9 +44,10 @@ if not DEBUG: INTERNAL_IPS = ['127.0.0.1'] -ADMINS = ( +# TODO This will conflict with merging the auth refactor +ADMINS = [ ('Tom Price', 'tomtom5152@gmail.com') -) +] # Application definition @@ -168,6 +169,8 @@ RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY', "6LeIxAcTAAAAAJcZV RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY', "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe") # If not set, use development key NOCAPTCHA = True +SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error'] + # Email EMAILER_TEST = False if not DEBUG or EMAILER_TEST: diff --git a/RIGS/migrations/0036_auto_20200208_1342.py b/RIGS/migrations/0036_auto_20200208_1342.py new file mode 100644 index 00000000..4c86d115 --- /dev/null +++ b/RIGS/migrations/0036_auto_20200208_1342.py @@ -0,0 +1,37 @@ +# Generated by Django 3.0.3 on 2020-02-08 13:42 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0035_auto_20191124_1319'), + ] + + operations = [ + migrations.AlterModelOptions( + name='event', + options={}, + ), + migrations.AlterModelOptions( + name='invoice', + options={'ordering': ['-invoice_date']}, + ), + migrations.AlterModelOptions( + name='organisation', + options={}, + ), + migrations.AlterModelOptions( + name='person', + options={}, + ), + migrations.AlterModelOptions( + name='profile', + options={'verbose_name': 'user', 'verbose_name_plural': 'users'}, + ), + migrations.AlterModelOptions( + name='venue', + options={}, + ), + ] diff --git a/RIGS/models.py b/RIGS/models.py index 937d5354..f68ecbcd 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -8,7 +8,6 @@ from django.contrib.auth.models import AbstractUser from django.conf import settings from django.utils import timezone from django.utils.functional import cached_property -from django.utils.encoding import python_2_unicode_compatible from reversion import revisions as reversion from reversion.models import Version import string @@ -22,7 +21,6 @@ from django.urls import reverse_lazy # Create your models here. -@python_2_unicode_compatible class Profile(AbstractUser): initials = models.CharField(max_length=5, unique=True, null=True, blank=False) phone = models.CharField(max_length=13, null=True, blank=True) @@ -56,11 +54,6 @@ class Profile(AbstractUser): def __str__(self): return self.name - class Meta: - permissions = ( - ('view_profile', 'Can view Profile'), - ) - class RevisionMixin(object): @property @@ -91,7 +84,6 @@ class RevisionMixin(object): @reversion.register -@python_2_unicode_compatible class Person(models.Model, RevisionMixin): name = models.CharField(max_length=50) phone = models.CharField(max_length=15, blank=True, null=True) @@ -127,14 +119,8 @@ class Person(models.Model, RevisionMixin): def get_absolute_url(self): return reverse_lazy('person_detail', kwargs={'pk': self.pk}) - class Meta: - permissions = ( - ('view_person', 'Can view Persons'), - ) - @reversion.register -@python_2_unicode_compatible class Organisation(models.Model, RevisionMixin): name = models.CharField(max_length=50) phone = models.CharField(max_length=15, blank=True, null=True) @@ -171,11 +157,6 @@ class Organisation(models.Model, RevisionMixin): def get_absolute_url(self): return reverse_lazy('organisation_detail', kwargs={'pk': self.pk}) - class Meta: - permissions = ( - ('view_organisation', 'Can view Organisations'), - ) - class VatManager(models.Manager): def current_rate(self): @@ -192,7 +173,6 @@ class VatManager(models.Manager): @reversion.register -@python_2_unicode_compatible class VatRate(models.Model, RevisionMixin): start_at = models.DateField() rate = models.DecimalField(max_digits=6, decimal_places=6) @@ -213,7 +193,6 @@ class VatRate(models.Model, RevisionMixin): @reversion.register -@python_2_unicode_compatible class Venue(models.Model, RevisionMixin): name = models.CharField(max_length=255) phone = models.CharField(max_length=15, blank=True, null=True) @@ -236,11 +215,6 @@ class Venue(models.Model, RevisionMixin): def get_absolute_url(self): return reverse_lazy('venue_detail', kwargs={'pk': self.pk}) - class Meta: - permissions = ( - ('view_venue', 'Can view Venues'), - ) - class EventManager(models.Manager): def current_events(self): @@ -287,7 +261,6 @@ class EventManager(models.Manager): @reversion.register(follow=['items']) -@python_2_unicode_compatible class Event(models.Model, RevisionMixin): # Done to make it much nicer on the database PROVISIONAL = 0 @@ -481,11 +454,6 @@ class Event(models.Model, RevisionMixin): self.full_clean() super(Event, self).save(*args, **kwargs) - class Meta: - permissions = ( - ('view_event', 'Can view Events'), - ) - class EventItem(models.Model): event = models.ForeignKey('Event', related_name='items', blank=True, on_delete=models.CASCADE) @@ -523,7 +491,7 @@ class EventAuthorisation(models.Model, RevisionMixin): uni_id = models.CharField(max_length=10, blank=True, null=True, verbose_name="University ID") account_code = models.CharField(max_length=50, blank=True, null=True) amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="authorisation amount") - sent_by = models.ForeignKey('RIGS.Profile', on_delete=models.CASCADE) + sent_by = models.ForeignKey('Profile', on_delete=models.CASCADE) def get_absolute_url(self): return reverse_lazy('event_detail', kwargs={'pk': self.event.pk}) @@ -533,7 +501,6 @@ class EventAuthorisation(models.Model, RevisionMixin): return str("N%05d" % self.event.pk + ' (requested by ' + self.sent_by.initials + ')') -@python_2_unicode_compatible class Invoice(models.Model): event = models.OneToOneField('Event', on_delete=models.CASCADE) invoice_date = models.DateField(auto_now_add=True) @@ -566,13 +533,9 @@ class Invoice(models.Model): return "%i: %s (%.2f)" % (self.pk, self.event, self.balance) class Meta: - permissions = ( - ('view_invoice', 'Can view Invoices'), - ) ordering = ['-invoice_date'] -@python_2_unicode_compatible class Payment(models.Model): CASH = 'C' INTERNAL = 'I' diff --git a/RIGS/urls.py b/RIGS/urls.py index 46e70f10..9de5a494 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -from django.contrib.auth.views import password_reset +from django.contrib.auth.views import PasswordResetView from django.contrib.auth.decorators import login_required from RIGS import models, views, rigboard, finance, ical, versioning, forms @@ -19,7 +19,7 @@ urlpatterns = [ url('^user/login/$', views.login, name='login'), url('^user/login/embed/$', xframe_options_exempt(views.login_embed), name='login_embed'), - url(r'^user/password_reset/$', views.PasswordResetDisabled.as_view()), + url(r'^user/password_reset/$', PasswordResetView.as_view()), # People url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonList.as_view()), diff --git a/assets/migrations/0006_auto_20180728_1451_squashed_0021_auto_20190105_1156.py b/assets/migrations/0006_auto_20180728_1451_squashed_0021_auto_20190105_1156.py index f15341e1..dcf7980e 100644 --- a/assets/migrations/0006_auto_20180728_1451_squashed_0021_auto_20190105_1156.py +++ b/assets/migrations/0006_auto_20180728_1451_squashed_0021_auto_20190105_1156.py @@ -57,7 +57,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='asset', name='parent', - field=models.ForeignKey(blank=True, null=True, on_delete=None, related_name='asset_parent', to='assets.Asset'), + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='asset_parent', to='assets.Asset'), ), migrations.RemoveField( model_name='asset', @@ -85,7 +85,7 @@ class Migration(migrations.Migration): ('circuits', models.IntegerField(blank=True, null=True)), ('cores', models.IntegerField(blank=True, null=True)), ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.AssetCategory')), - ('parent', models.ForeignKey(blank=True, null=True, on_delete=None, related_name='asset_parent', to='assets.Cable')), + ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='asset_parent', to='assets.Cable')), ], options={ 'abstract': False, diff --git a/assets/migrations/0010_auto_20200208_1342.py b/assets/migrations/0010_auto_20200208_1342.py new file mode 100644 index 00000000..2962a558 --- /dev/null +++ b/assets/migrations/0010_auto_20200208_1342.py @@ -0,0 +1,21 @@ +# Generated by Django 3.0.3 on 2020-02-08 13:42 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('assets', '0009_auto_20200103_2215'), + ] + + operations = [ + migrations.AlterModelOptions( + name='asset', + options={'ordering': ['asset_id_prefix', 'asset_id_number'], 'permissions': [('asset_finance', 'Can see financial data for assets')]}, + ), + migrations.AlterModelOptions( + name='supplier', + options={}, + ), + ] diff --git a/assets/models.py b/assets/models.py index 5bf830bc..7bf65260 100644 --- a/assets/models.py +++ b/assets/models.py @@ -43,12 +43,6 @@ class AssetStatus(models.Model): class Supplier(models.Model, RevisionMixin): name = models.CharField(max_length=80) - class Meta: - ordering = ['name'] - permissions = ( - ('view_supplier', 'Can view a supplier'), - ) - def get_absolute_url(self): return reverse('supplier_list') @@ -70,10 +64,9 @@ class Connector(models.Model): class Asset(models.Model, RevisionMixin): class Meta: ordering = ['asset_id_prefix', 'asset_id_number'] - permissions = ( - ('asset_finance', 'Can see financial data for assets'), - ('view_asset', 'Can view an asset') - ) + permissions = [ + ('asset_finance', 'Can see financial data for assets') + ] parent = models.ForeignKey(to='self', related_name='asset_parent', blank=True, null=True, on_delete=models.SET_NULL) diff --git a/templates/base.html b/templates/base.html index a902a7ab..c5aae95e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,4 @@ -{% load static from staticfiles %} +{% load static %} {% load raven %}