mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-12 17:49:41 +00:00
Compare commits
19 Commits
estates-co
...
2171d7fda9
| Author | SHA1 | Date | |
|---|---|---|---|
|
2171d7fda9
|
|||
|
3c4ccfb103
|
|||
|
04c7e4b518
|
|||
|
beb0ba915d
|
|||
|
ac15ab3729
|
|||
|
15230cb361
|
|||
|
b5b8dc104c
|
|||
|
55aa41acfd
|
|||
|
63eb3bebef
|
|||
|
f76222763d
|
|||
|
32c8573c71
|
|||
|
146dbb3be7
|
|||
|
c2cb73f73d
|
|||
|
e440ef88d4
|
|||
|
13fec124c6
|
|||
|
e842471b9e
|
|||
|
039f9f68d3
|
|||
| 2c808d0adf | |||
| 76cd5459fc |
2
Pipfile
2
Pipfile
@@ -39,7 +39,7 @@ premailer = "~=3.7.0"
|
||||
progress = "~=1.5"
|
||||
psutil = "~=5.8.0"
|
||||
psycopg2 = "~=2.8.6"
|
||||
Pygments = "~=2.15.0"
|
||||
Pygments = "~=2.7.4"
|
||||
pyparsing = "~=2.4.7"
|
||||
PyPDF2 = "~=1.27.5"
|
||||
PyPOM = "~=2.2.4"
|
||||
|
||||
794
Pipfile.lock
generated
794
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -121,7 +121,3 @@ def nottinghamtec_address_required(function):
|
||||
return function(request, *args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
|
||||
def not_estates():
|
||||
return user_passes_test_with_403(lambda u: not u.email.endswith('@nottingham.ac.uk'))
|
||||
0
PyRIGS/forms.py
Normal file
0
PyRIGS/forms.py
Normal file
@@ -35,9 +35,6 @@ if DEBUG:
|
||||
ALLOWED_HOSTS.append('localhost')
|
||||
ALLOWED_HOSTS.append('example.com')
|
||||
ALLOWED_HOSTS.append('127.0.0.1')
|
||||
ALLOWED_HOSTS.append('.github.dev')
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS
|
||||
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
if not DEBUG:
|
||||
|
||||
@@ -6,8 +6,6 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.urls import path
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from PyRIGS.decorators import not_estates
|
||||
|
||||
from PyRIGS import views
|
||||
|
||||
urlpatterns = [
|
||||
@@ -16,17 +14,17 @@ urlpatterns = [
|
||||
path('assets/', include('assets.urls')),
|
||||
path('training/', include('training.urls')),
|
||||
|
||||
path('', not_estates()(views.Index.as_view()), name='index'),
|
||||
path('', login_required(views.Index.as_view()), name='index'),
|
||||
|
||||
# API
|
||||
path('api/<str:model>/', not_estates()(views.SecureAPIRequest.as_view()),
|
||||
path('api/<str:model>/', login_required(views.SecureAPIRequest.as_view()),
|
||||
name="api_secure"),
|
||||
path('api/<str:model>/<int:pk>/', not_estates()(views.SecureAPIRequest.as_view()),
|
||||
path('api/<str:model>/<int:pk>/', login_required(views.SecureAPIRequest.as_view()),
|
||||
name="api_secure"),
|
||||
|
||||
path('closemodal/', views.CloseModal.as_view(), name='closemodal'),
|
||||
path('search/', not_estates()(views.Search.as_view()), name='search'),
|
||||
path('search_help/', not_estates()(views.SearchHelp.as_view()), name='search_help'),
|
||||
path('search/', login_required(views.Search.as_view()), name='search'),
|
||||
path('search_help/', login_required(views.SearchHelp.as_view()), name='search_help'),
|
||||
|
||||
path('', include('users.urls')),
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Index(generic.TemplateView): # Displays the current rig count along with
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['rig_count'] = models.Event.objects.rig_count()
|
||||
context['now'] = models.Event.objects.events_in_bounds(timezone.now(), timezone.now()).exclude(status=models.Event.CANCELLED).filter(is_rig=True, dry_hire=False)
|
||||
context['now'] = models.Event.objects.events_in_bounds(timezone.now(), timezone.now()).exclude(dry_hire=True).exclude(status=models.Event.CANCELLED)
|
||||
return context
|
||||
|
||||
|
||||
@@ -134,9 +134,6 @@ class SecureAPIRequest(generic.View):
|
||||
results = []
|
||||
query = reduce(operator.and_, queries)
|
||||
objects = self.models[model].objects.filter(query)
|
||||
# Returning unactivated or unapproved users when they are elsewhere filtered out of the default queryset leads to some *very* unexpected results
|
||||
if model == "profile":
|
||||
objects = objects.filter(is_active=True, is_approved=True)
|
||||
for o in objects:
|
||||
name = o.display_name if hasattr(o, 'display_name') else o.name
|
||||
data = {
|
||||
|
||||
@@ -154,9 +154,8 @@ class AssociateAdmin(VersionAdmin):
|
||||
|
||||
@admin.register(models.Profile)
|
||||
class ProfileAdmin(UserAdmin, AssociateAdmin):
|
||||
list_display = ('username', 'name', 'is_approved', 'is_superuser', 'is_supervisor', 'number_of_events', 'last_login')
|
||||
list_display = ('username', 'name', 'is_approved', 'is_staff', 'is_superuser', 'is_supervisor', 'number_of_events')
|
||||
list_display_links = ['username']
|
||||
list_filter = UserAdmin.list_filter + ('is_approved',)
|
||||
fieldsets = (
|
||||
(None, {'fields': ('username', 'password')}),
|
||||
(_('Personal info'), {
|
||||
|
||||
@@ -121,7 +121,7 @@ class EventForm(forms.ModelForm):
|
||||
fields = ['is_rig', 'name', 'venue', 'start_time', 'end_date', 'start_date',
|
||||
'end_time', 'meet_at', 'access_at', 'description', 'notes', 'mic',
|
||||
'person', 'organisation', 'dry_hire', 'checked_in_by', 'status',
|
||||
'purchase_order', 'collector', 'forum_url']
|
||||
'purchase_order', 'collector']
|
||||
|
||||
|
||||
class BaseClientEventAuthorisationForm(forms.ModelForm):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# Generated by Django 3.2.19 on 2023-06-27 11:28
|
||||
# Generated by Django 3.2.18 on 2023-06-26 17:46
|
||||
|
||||
import RIGS.models
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
@@ -14,6 +13,6 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='forum_url',
|
||||
field=models.URLField(blank=True, default='', validators=[RIGS.models.validate_forum_url]),
|
||||
field=models.URLField(blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Generated by Django 3.2.19 on 2023-07-09 21:23
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0050_event_forum_url'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='payment',
|
||||
name='method',
|
||||
field=models.CharField(blank=True, choices=[('C', 'Cash'), ('I', 'Internal'), ('E', 'External'), ('T', 'TEC Adjustment')], default='', max_length=2),
|
||||
),
|
||||
]
|
||||
@@ -1,18 +0,0 @@
|
||||
# Generated by Django 3.2.21 on 2023-09-05 22:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0051_alter_payment_method'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='venue',
|
||||
name='on_campus',
|
||||
field=models.BooleanField(default=False, verbose_name='Is this venue on a UoN campus?'),
|
||||
),
|
||||
]
|
||||
@@ -76,8 +76,7 @@ class Profile(AbstractUser):
|
||||
|
||||
@classmethod
|
||||
def users_awaiting_approval_count(cls):
|
||||
# last_login = None ensures we only pick up genuinely new users, not those that have been deactivated for inactivity
|
||||
return Profile.objects.filter(is_approved=False, last_login=None).count()
|
||||
return Profile.objects.filter(models.Q(is_approved=False)).count()
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -213,7 +212,6 @@ class Venue(models.Model, RevisionMixin):
|
||||
phone = models.CharField(max_length=15, blank=True, default='')
|
||||
email = models.EmailField(blank=True, default='')
|
||||
three_phase_available = models.BooleanField(default=False)
|
||||
on_campus = models.BooleanField(default=False, verbose_name="Is this venue on a UoN campus?")
|
||||
notes = models.TextField(blank=True, default='')
|
||||
address = models.TextField(blank=True, default='')
|
||||
|
||||
@@ -310,14 +308,6 @@ class EventManager(models.Manager):
|
||||
return qs
|
||||
|
||||
|
||||
def validate_forum_url(value):
|
||||
if not value:
|
||||
return # Required error is done the field
|
||||
obj = urlparse(value)
|
||||
if obj.hostname not in ('forum.nottinghamtec.co.uk'):
|
||||
raise ValidationError('URL must point to a location on the TEC Forum')
|
||||
|
||||
|
||||
@reversion.register(follow=['items'])
|
||||
class Event(models.Model, RevisionMixin):
|
||||
# Done to make it much nicer on the database
|
||||
@@ -367,7 +357,7 @@ class Event(models.Model, RevisionMixin):
|
||||
auth_request_at = models.DateTimeField(null=True, blank=True)
|
||||
auth_request_to = models.EmailField(blank=True, default='')
|
||||
|
||||
forum_url = models.URLField(default='', blank=True, validators=[validate_forum_url])
|
||||
forum_url = models.URLField(null=True, blank=True)
|
||||
|
||||
@property
|
||||
def display_id(self):
|
||||
@@ -517,7 +507,7 @@ class Event(models.Model, RevisionMixin):
|
||||
return reverse('event_detail', kwargs={'pk': self.pk})
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.display_id} | {self.name}"
|
||||
return f"{self.display_id}: {self.name}"
|
||||
|
||||
def clean(self):
|
||||
errdict = {}
|
||||
@@ -689,11 +679,13 @@ class Payment(models.Model, RevisionMixin):
|
||||
CASH = 'C'
|
||||
INTERNAL = 'I'
|
||||
EXTERNAL = 'E'
|
||||
SUCORE = 'SU'
|
||||
ADJUSTMENT = 'T'
|
||||
METHODS = (
|
||||
(CASH, 'Cash'),
|
||||
(INTERNAL, 'Internal'),
|
||||
(EXTERNAL, 'External'),
|
||||
(SUCORE, 'SU Core'),
|
||||
(ADJUSTMENT, 'TEC Adjustment'),
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{% extends 'base_client.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% include 'estates/estates_event_table.html' %}
|
||||
{% endblock %}
|
||||
@@ -1,78 +0,0 @@
|
||||
{% load namewithnotes from filters %}
|
||||
{% load markdown_tags %}
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0" id="event_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Dates & Times</th>
|
||||
<th scope="col">Event Details</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Member In Charge</th>
|
||||
<th scope="col">Power Plan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for event in events %}
|
||||
<tr {% if event.cancelled %}style="opacity: 50% !important;"{% endif %} id="event_row">
|
||||
<!---Number-->
|
||||
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
||||
<!--Dates & Times-->
|
||||
<td id="event_dates" style="text-align: justify;">
|
||||
<span class="text-nowrap">Start: <strong>{{ event.start_date|date:"D d/m/Y" }}
|
||||
{% if event.has_start_time %}
|
||||
{{ event.start_time|date:"H:i" }}
|
||||
{% endif %}</strong>
|
||||
</span>
|
||||
{% if event.end_date %}
|
||||
<br>
|
||||
<span class="text-nowrap">End: {% if event.end_date != event.start_date %}<strong>{{ event.end_date|date:"D d/m/Y" }}{% endif %}
|
||||
{% if event.has_end_time %}
|
||||
{{ event.end_time|date:"H:i" }}
|
||||
{% endif %}</strong>
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<!---Details-->
|
||||
<td id="event_details" class="w-100">
|
||||
<h4>
|
||||
{{ event.name }}
|
||||
{% if event.venue %}
|
||||
<small>at {{ event.venue }}</small>
|
||||
{% endif %}
|
||||
</h4>
|
||||
{% if event.is_rig and not event.cancelled %}
|
||||
<h5>
|
||||
{{ event.person.name }}
|
||||
{% if event.organisation %}
|
||||
for {{ event.organisation.name }}
|
||||
{% endif %}
|
||||
</h5>
|
||||
{% endif %}
|
||||
{% if not event.cancelled and event.description %}
|
||||
<p>{{ event.description|markdown }}</p>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ event.get_status_display }}
|
||||
</td>
|
||||
<!---MIC-->
|
||||
<td id="event_mic" class="text-nowrap">
|
||||
{% if event.mic %}
|
||||
{{ event.mic }}
|
||||
{% elif event.is_rig %}
|
||||
<span class="fas fa-user-slash"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ event.riskassessment.power_plan|default:"Pending" }}
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr class="bg-warning">
|
||||
<td colspan="4">No events found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -231,7 +231,7 @@
|
||||
<label for="{{ form.start_date.id_for_label }}"
|
||||
class="col-sm-4 col-form-label">{{ form.start_date.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="Start date for event, required">
|
||||
{% render_field form.start_date class+="form-control" %}
|
||||
@@ -246,7 +246,7 @@
|
||||
<label for="{{ form.end_date.id_for_label }}"
|
||||
class="col-sm-4 col-form-label">{{ form.end_date.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="End date of event, leave blank if unknown or same as start date">
|
||||
{% render_field form.end_date class+="form-control" %}
|
||||
@@ -334,26 +334,12 @@
|
||||
|
||||
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
|
||||
<label for="{{ form.purchase_order.id_for_label }}"
|
||||
class="col-sm-4 col-form-label">{{ form.purchase_order.label }}</label>
|
||||
class="col-sm-4 col-fitem_tableorm-label">{{ form.purchase_order.label }}</label>
|
||||
|
||||
<div class="col-sm-8">
|
||||
{% render_field form.purchase_order class+="form-control" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" data-toggle="tooltip" title="The thread for this event on the TEC Forum">
|
||||
<label for="{{ form.forum_url.id_for_label }}"
|
||||
class="col-sm-4 col-form-label">Forum Thread</label>
|
||||
<div class="col-sm-12">
|
||||
<p class="small mb-0">Paste URL</p>
|
||||
{% render_field form.forum_url class+="form-control" %}
|
||||
{% if object.pk %}
|
||||
<p class="small mb-0">or</p>
|
||||
<a href="{% url 'event_thread' object.pk %}" class="btn btn-primary" title="Create Forum Thread" target="_blank">
|
||||
<span class="fas fa-plus"></span> <span class="hidden-xs">Create Forum Thread</span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -165,11 +165,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 text-right">
|
||||
{% button 'edit' url='pt_edit' pk=object.pk %}
|
||||
{% button 'view' url='event_detail' pk=object.event.pk text="Event" %}
|
||||
{% include 'partials/review_status.html' with perm=perms.RIGS.review_power review='pt_review' %}
|
||||
{% button 'edit' url='ec_edit' pk=object.pk %}
|
||||
{% button 'view' url='event_detail' pk=object.pk text="Event" %}
|
||||
{% include 'partials/review_status.html' with perm=perms.RIGS.review_eventchecklist review='ec_review' %}
|
||||
</div>
|
||||
<div class="col-12 text-right">
|
||||
{% include 'partials/last_edited.html' with target="powertestrecord_history" %}
|
||||
{% include 'partials/last_edited.html' with target="eventchecklist_history" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -79,10 +79,10 @@
|
||||
{% endif %}
|
||||
|
||||
<dt class="col-6">Forum Thread</dt>
|
||||
{% if object.forum_url %}
|
||||
<dd class="col-6"><a href="{{object.forum_url}}">{{object.forum_url}}</a></dd>
|
||||
{% if event.forum_thread %}
|
||||
<dd class="col-6"><a href="{{event.forum_thread}}">{{event.forum_thread}}</a></dd>
|
||||
{% else %}
|
||||
<a href="{% url 'event_thread' object.pk %}" class="btn btn-primary" title="Create Forum Thread" target="_blank"><span
|
||||
<a href="{% url 'event_thread' event.pk %}" class="btn btn-primary" title="Create Forum Thread"><span
|
||||
class="fas fa-plus"></span> <span
|
||||
class="hidden-xs">Create Forum Thread</span></a>
|
||||
{% endif %}
|
||||
|
||||
@@ -29,15 +29,7 @@
|
||||
</div>
|
||||
<div class="row pt-3">
|
||||
<label class="col-sm-4 col-form-label"
|
||||
for="{{ form.method.id_for_label }}">{{ form.method.label }}
|
||||
<span class="fas fa-info-circle text-info" data-toggle="collapse" data-target="#collapse" aria-expanded="false" aria-controls="collapse"></span>
|
||||
<ul class="collapse" id="collapse">
|
||||
<li>Cash - Self Explanatory</li>
|
||||
<li>Internal - Transfers within the Students' Union only</li>
|
||||
<li>External - All other transfers (<em>including</em> the University)</li>
|
||||
<li>TEC Adjustment - Manual corrections</li>
|
||||
</ul>
|
||||
</label>
|
||||
for="{{ form.method.id_for_label }}">{{ form.method.label }}</label>
|
||||
<div class="col-sm-8">
|
||||
{% render_field form.method class+="form-control" %}
|
||||
</div>
|
||||
|
||||
27
RIGS/urls.py
27
RIGS/urls.py
@@ -4,7 +4,7 @@ from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
from PyRIGS.decorators import (api_key_required, has_oembed,
|
||||
permission_required_with_403, not_estates)
|
||||
permission_required_with_403)
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
@@ -42,22 +42,21 @@ urlpatterns = [
|
||||
name='venue_update'),
|
||||
|
||||
# Rigboard
|
||||
path('rigboard/', not_estates()(views.RigboardIndex.as_view()), name='rigboard'),
|
||||
path('rigboard/calendar/', not_estates()(views.WebCalendar.as_view()),
|
||||
path('rigboard/', login_required(views.RigboardIndex.as_view()), name='rigboard'),
|
||||
path('rigboard/calendar/', login_required()(views.WebCalendar.as_view()),
|
||||
name='web_calendar'),
|
||||
re_path(r'^rigboard/calendar/(?P<view>(month|week|day))/$',
|
||||
not_estates()(views.WebCalendar.as_view()), name='web_calendar'),
|
||||
login_required()(views.WebCalendar.as_view()), name='web_calendar'),
|
||||
re_path(r'^rigboard/calendar/(?P<view>(month|week|day))/(?P<date>(\d{4}-\d{2}-\d{2}))/$',
|
||||
not_estates()(views.WebCalendar.as_view()), name='web_calendar'),
|
||||
login_required()(views.WebCalendar.as_view()), name='web_calendar'),
|
||||
path('rigboard/archive/', RedirectView.as_view(permanent=True, pattern_name='event_archive')),
|
||||
|
||||
path('estates/', login_required()(views.EstatesEventList.as_view()), name='estates'),
|
||||
|
||||
path('event/<int:pk>/', has_oembed(oembed_view="event_oembed")(views.EventDetail.as_view()),
|
||||
name='event_detail'),
|
||||
path('event/create/', permission_required_with_403('RIGS.add_event')(views.EventCreate.as_view()),
|
||||
name='event_create'),
|
||||
path('event/archive/', not_estates()(views.EventArchive.as_view()),
|
||||
path('event/archive/', login_required()(views.EventArchive.as_view()),
|
||||
name='event_archive'),
|
||||
path('event/<int:pk>/embed/',
|
||||
xframe_options_exempt(login_required(login_url='/user/login/embed/')(views.EventEmbed.as_view())),
|
||||
@@ -76,7 +75,7 @@ urlpatterns = [
|
||||
|
||||
path('event/<int:pk>/ra/', permission_required_with_403('RIGS.add_riskassessment')(views.EventRiskAssessmentCreate.as_view()),
|
||||
name='event_ra'),
|
||||
path('event/ra/<int:pk>/', not_estates()(views.EventRiskAssessmentDetail.as_view()),
|
||||
path('event/ra/<int:pk>/', login_required(views.EventRiskAssessmentDetail.as_view()),
|
||||
name='ra_detail'),
|
||||
path('event/ra/<int:pk>/edit/', permission_required_with_403('RIGS.change_riskassessment')(views.EventRiskAssessmentEdit.as_view()),
|
||||
name='ra_edit'),
|
||||
@@ -86,7 +85,7 @@ urlpatterns = [
|
||||
|
||||
path('event/<int:pk>/checklist/', permission_required_with_403('RIGS.add_eventchecklist')(views.EventChecklistCreate.as_view()),
|
||||
name='event_ec'),
|
||||
path('event/checklist/<int:pk>/', not_estates()(views.EventChecklistDetail.as_view()),
|
||||
path('event/checklist/<int:pk>/', login_required(views.EventChecklistDetail.as_view()),
|
||||
name='ec_detail'),
|
||||
path('event/checklist/<int:pk>/edit/', permission_required_with_403('RIGS.change_eventchecklist')(views.EventChecklistEdit.as_view()),
|
||||
name='ec_edit'),
|
||||
@@ -95,20 +94,20 @@ urlpatterns = [
|
||||
|
||||
path('event/<int:pk>/power/', permission_required_with_403('RIGS.add_powertestrecord')(views.PowerTestCreate.as_view()),
|
||||
name='event_pt'),
|
||||
path('event/power/<int:pk>/', not_estates()(views.PowerTestDetail.as_view()),
|
||||
path('event/power/<int:pk>/', login_required(views.PowerTestDetail.as_view()),
|
||||
name='pt_detail'),
|
||||
path('event/power/<int:pk>/edit/', permission_required_with_403('RIGS.change_powertestrecord')(views.PowerTestEdit.as_view()),
|
||||
name='pt_edit'),
|
||||
path('event/power/<int:pk>/review/', permission_required_with_403('RIGS.review_power')(views.MarkReviewed.as_view()),
|
||||
name='pt_review', kwargs={'model': 'PowerTestRecord'}),
|
||||
|
||||
path('event/<int:pk>/checkin/', not_estates()(views.EventCheckIn.as_view()),
|
||||
path('event/<int:pk>/checkin/', login_required(views.EventCheckIn.as_view()),
|
||||
name='event_checkin'),
|
||||
path('event/checkout/', not_estates()(views.EventCheckOut.as_view()),
|
||||
path('event/checkout/', login_required(views.EventCheckOut.as_view()),
|
||||
name='event_checkout'),
|
||||
path('event/<int:pk>/checkin/edit/', not_estates()(views.EventCheckInEdit.as_view()),
|
||||
path('event/<int:pk>/checkin/edit/', login_required(views.EventCheckInEdit.as_view()),
|
||||
name='edit_checkin'),
|
||||
path('event/<int:pk>/checkin/add/', not_estates()(views.EventCheckInOverride.as_view()),
|
||||
path('event/<int:pk>/checkin/add/', login_required(views.EventCheckInOverride.as_view()),
|
||||
name='event_checkin_override'),
|
||||
|
||||
path('event/<int:pk>/thread/', permission_required_with_403('RIGS.change_event')(views.CreateForumThread.as_view()), name='event_thread'),
|
||||
|
||||
@@ -115,7 +115,7 @@ class VenueDetail(GenericDetailView):
|
||||
|
||||
class VenueCreate(GenericCreateView, ModalURLMixin):
|
||||
model = models.Venue
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'three_phase_available', 'on_campus']
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'three_phase_available']
|
||||
|
||||
def get_success_url(self):
|
||||
return self.get_close_url('venue_update', 'venue_detail')
|
||||
@@ -123,7 +123,7 @@ class VenueCreate(GenericCreateView, ModalURLMixin):
|
||||
|
||||
class VenueUpdate(GenericUpdateView, ModalURLMixin):
|
||||
model = models.Venue
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'three_phase_available', 'on_campus']
|
||||
fields = ['name', 'phone', 'email', 'address', 'notes', 'three_phase_available']
|
||||
|
||||
def get_success_url(self):
|
||||
return self.get_close_url('venue_update', 'venue_detail')
|
||||
|
||||
@@ -26,7 +26,6 @@ from django.utils import timezone
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import generic
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||
|
||||
from PyRIGS import decorators
|
||||
from PyRIGS.views import OEmbedView, is_ajax, ModalURLMixin, PrintView, get_related
|
||||
@@ -411,29 +410,14 @@ class RecieveForumWebhook(generic.View):
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
computed = f"sha256={hmac.new(env('FORUM_WEBHOOK_SECRET').encode(), request.body, hashlib.sha256).hexdigest()}"
|
||||
print(computed)
|
||||
if not hmac.compare_digest(request.headers.get('X-Discourse-Event-Signature'), computed):
|
||||
return HttpResponseForbidden('Invalid signature header')
|
||||
# Check if this is the right kind of event. The webhook filters by category on the forum side
|
||||
if request.headers.get('X-Discourse-Event') == "topic_created":
|
||||
body = simplejson.loads(request.body.decode('utf-8'))
|
||||
event_id = int(body['topic']['title'][1:6]) # find the ID, force convert it to an int to eliminate leading zeros
|
||||
event = models.Event.objects.filter(pk=event_id).first()
|
||||
if event:
|
||||
event.forum_url = f"https://forum.nottinghamtec.co.uk/t/{body['topic']['slug']}"
|
||||
event.save()
|
||||
return HttpResponse(status=202)
|
||||
body = simplejson.loads(request.body.decode('utf-8'))
|
||||
event_id = int(body['topic']['title'][1:6]) # find the ID, force convert it to an int to eliminate leading zeros
|
||||
event = models.Event.objects.filter(pk=event_id).first()
|
||||
if event:
|
||||
event.forum_url = f"https://forum.nottinghamtec.co.uk/t/{body['topic']['slug']}"
|
||||
event.save()
|
||||
return HttpResponse(status=202)
|
||||
return HttpResponse(status=204)
|
||||
|
||||
class EstatesEventList(UserPassesTestMixin, generic.TemplateView):
|
||||
template_name = 'estates/estates_event_list.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
# get super context
|
||||
context = super().get_context_data(**kwargs)
|
||||
# call out method to get current events
|
||||
context['events'] = models.Event.objects.current_events().filter(venue__on_campus=True, dry_hire=False, is_rig=True)
|
||||
context['page_title'] = "Upcoming Campus Events"
|
||||
return context
|
||||
|
||||
def test_func(self):
|
||||
return self.request.user.email.endswith('@nottingham.ac.uk')
|
||||
@@ -38,17 +38,3 @@ def test_asset(db, category, status):
|
||||
asset, created = models.Asset.objects.get_or_create(asset_id="91991", description="Spaceflower", status=status, category=category, date_acquired=datetime.date(1991, 12, 26), replacement_cost=100)
|
||||
yield asset
|
||||
asset.delete()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_status_2(db):
|
||||
status = models.AssetStatus.objects.create(name="Lost", should_show=False)
|
||||
yield status
|
||||
status.delete()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_asset_2(db, category, test_status_2):
|
||||
asset, created = models.Asset.objects.get_or_create(asset_id="10", description="Working Mic", status=test_status_2, category=category, date_acquired=datetime.date(2001, 10, 20), replacement_cost=1000)
|
||||
yield asset
|
||||
asset.delete()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import time
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from django.utils import timezone
|
||||
from selenium.webdriver.common.by import By
|
||||
@@ -54,45 +53,45 @@ class TestAssetList(AutoLoginTest):
|
||||
self.assertEqual("10", asset_ids[2])
|
||||
self.assertEqual("C1", asset_ids[3])
|
||||
|
||||
def test_search(self):
|
||||
self.page.set_query("10")
|
||||
self.page.search()
|
||||
self.assertTrue(len(self.page.assets) == 1)
|
||||
self.assertEqual("Working Mic", self.page.assets[0].description)
|
||||
self.assertEqual("10", self.page.assets[0].id)
|
||||
|
||||
@pytest.mark.xfail(reason="Fails on CI for unknown reason", raises=AssertionError)
|
||||
def test_search(logged_in_browser, admin_user, live_server, test_asset, test_asset_2, category, status, cable_type):
|
||||
page = pages.AssetList(logged_in_browser.driver, live_server.url).open()
|
||||
page.set_query(test_asset.asset_id)
|
||||
page.search()
|
||||
assert len(page.assets) == 1
|
||||
assert page.assets[0].description == test_asset.description
|
||||
assert page.assets[0].id == test_asset.asset_id
|
||||
self.page.set_query("light")
|
||||
self.page.search()
|
||||
self.assertTrue(len(self.page.assets) == 1)
|
||||
self.assertEqual("A light", self.page.assets[0].description)
|
||||
|
||||
page.set_query(test_asset.description)
|
||||
page.search()
|
||||
assert len(page.assets) == 1
|
||||
assert page.assets[0].description == test_asset.description
|
||||
self.page.set_query("Random string")
|
||||
self.page.search()
|
||||
self.assertTrue(len(self.page.assets) == 0)
|
||||
|
||||
page.set_query("Random string")
|
||||
page.search()
|
||||
assert len(page.assets) == 0
|
||||
self.page.set_query("")
|
||||
self.page.search()
|
||||
# Only working stuff shown by default
|
||||
self.assertTrue(len(self.page.assets) == 2)
|
||||
|
||||
page.set_query("")
|
||||
page.search()
|
||||
# Only working stuff shown by default
|
||||
assert len(page.assets) == 1
|
||||
self.page.status_selector.toggle()
|
||||
self.assertTrue(self.page.status_selector.is_open)
|
||||
self.page.status_selector.select_all()
|
||||
self.page.status_selector.toggle()
|
||||
self.assertFalse(self.page.status_selector.is_open)
|
||||
self.page.filter()
|
||||
self.assertTrue(len(self.page.assets) == 4)
|
||||
|
||||
page.status_selector.toggle()
|
||||
assert page.status_selector.is_open
|
||||
page.status_selector.select_all()
|
||||
page.status_selector.toggle()
|
||||
assert not page.status_selector.is_open
|
||||
page.filter()
|
||||
assert len(page.assets) == 2
|
||||
|
||||
page.category_selector.toggle()
|
||||
assert page.category_selector.is_open
|
||||
page.category_selector.set_option(category.name, True)
|
||||
page.category_selector.close()
|
||||
assert not page.category_selector.is_open
|
||||
page.filter()
|
||||
assert len(page.assets) == 2
|
||||
self.page.category_selector.toggle()
|
||||
self.assertTrue(self.page.category_selector.is_open)
|
||||
self.page.category_selector.set_option("Sound", True)
|
||||
self.page.category_selector.close()
|
||||
self.assertFalse(self.page.category_selector.is_open)
|
||||
self.page.filter()
|
||||
self.assertTrue(len(self.page.assets) == 2)
|
||||
asset_ids = list(map(lambda x: x.id, self.page.assets))
|
||||
self.assertEqual("1", asset_ids[0])
|
||||
self.assertEqual("10", asset_ids[1])
|
||||
|
||||
|
||||
def test_cable_create(logged_in_browser, admin_user, live_server, test_asset, category, status, cable_type):
|
||||
|
||||
@@ -2,7 +2,7 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.urls import path, register_converter
|
||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
|
||||
from PyRIGS.decorators import has_oembed, permission_required_with_403, not_estates
|
||||
from PyRIGS.decorators import has_oembed, permission_required_with_403
|
||||
from PyRIGS.views import OEmbedView
|
||||
from . import views, converters
|
||||
|
||||
@@ -10,8 +10,8 @@ register_converter(converters.AssetIDConverter, 'asset')
|
||||
register_converter(converters.ListConverter, 'list')
|
||||
|
||||
urlpatterns = [
|
||||
path('', not_estates()(views.AssetList.as_view()), name='asset_index'),
|
||||
path('asset/list/', not_estates()(views.AssetList.as_view()), name='asset_list'),
|
||||
path('', login_required(views.AssetList.as_view()), name='asset_index'),
|
||||
path('asset/list/', login_required(views.AssetList.as_view()), name='asset_list'),
|
||||
path('asset/id/<asset:pk>/', has_oembed(oembed_view="asset_oembed")(views.AssetDetail.as_view()), name='asset_detail'),
|
||||
path('asset/create/', permission_required_with_403('assets.add_asset')
|
||||
(views.AssetCreate.as_view()), name='asset_create'),
|
||||
@@ -19,26 +19,26 @@ urlpatterns = [
|
||||
(views.AssetEdit.as_view()), name='asset_update'),
|
||||
path('asset/id/<asset:pk>/duplicate/', permission_required_with_403('assets.add_asset')
|
||||
(views.AssetDuplicate.as_view()), name='asset_duplicate'),
|
||||
path('asset/id/<asset:pk>/label', not_estates()(views.GenerateLabel.as_view()), name='generate_label'),
|
||||
path('asset/id/<asset:pk>/label', login_required(views.GenerateLabel.as_view()), name='generate_label'),
|
||||
path('asset/<list:ids>/list/label', views.GenerateLabels.as_view(), name='generate_labels'),
|
||||
|
||||
path('cables/list/', not_estates()(views.CableList.as_view()), name='cable_list'),
|
||||
path('cabletype/list/', not_estates()(views.CableTypeList.as_view()), name='cable_type_list'),
|
||||
path('cables/list/', login_required(views.CableList.as_view()), name='cable_list'),
|
||||
path('cabletype/list/', login_required(views.CableTypeList.as_view()), name='cable_type_list'),
|
||||
path('cabletype/create/', permission_required_with_403('assets.add_cable_type')(views.CableTypeCreate.as_view()), name='cable_type_create'),
|
||||
path('cabletype/<int:pk>/update/', permission_required_with_403('assets.change_cable_type')(views.CableTypeUpdate.as_view()), name='cable_type_update'),
|
||||
path('cabletype/<int:pk>/detail/', not_estates()(views.CableTypeDetail.as_view()), name='cable_type_detail'),
|
||||
path('cabletype/<int:pk>/detail/', login_required(views.CableTypeDetail.as_view()), name='cable_type_detail'),
|
||||
|
||||
path('asset/id/<str:pk>/embed/',
|
||||
xframe_options_exempt(
|
||||
login_required(login_url='/user/login/embed/')(views.AssetEmbed.as_view())),
|
||||
login_required(login_url='/user/login/embed/')(views.AssetEmbed.as_view())),
|
||||
name='asset_embed'),
|
||||
path('asset/id/<str:pk>/oembed_json/', views.AssetOEmbed.as_view(), name='asset_oembed'),
|
||||
|
||||
path('asset/audit/', permission_required_with_403('assets.change_asset')(views.AssetAuditList.as_view()), name='asset_audit_list'),
|
||||
path('asset/id/<str:pk>/audit/', permission_required_with_403('assets.change_asset')(views.AssetAudit.as_view()), name='asset_audit'),
|
||||
|
||||
path('supplier/list/', not_estates()(views.SupplierList.as_view()), name='supplier_list'),
|
||||
path('supplier/<int:pk>/', not_estates()(views.SupplierDetail.as_view()), name='supplier_detail'),
|
||||
path('supplier/list/', login_required(views.SupplierList.as_view()), name='supplier_list'),
|
||||
path('supplier/<int:pk>/', login_required(views.SupplierDetail.as_view()), name='supplier_detail'),
|
||||
path('supplier/create/', permission_required_with_403('assets.add_supplier')
|
||||
(views.SupplierCreate.as_view()), name='supplier_create'),
|
||||
path('supplier/<int:pk>/edit/', permission_required_with_403('assets.change_supplier')
|
||||
|
||||
1282
package-lock.json
generated
1282
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@
|
||||
"jquery": "^3.6.0",
|
||||
"konami": "^1.6.3",
|
||||
"moment": "^2.29.4",
|
||||
"node-sass": "^9.0.0",
|
||||
"node-sass": "^7.0.3",
|
||||
"popper.js": "^1.16.1",
|
||||
"postcss": "^8.4.5",
|
||||
"uglify-js": "^3.14.5"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{% extends override|default:"base_rigs.html" %}
|
||||
{% load widget_tweaks %}
|
||||
{% load button from filters %}
|
||||
{% load verbose_name from filters %}
|
||||
{% load markdown_tags %}
|
||||
|
||||
{% block content %}
|
||||
@@ -31,11 +30,6 @@
|
||||
<dd>{{ object.three_phase_available|yesno|capfirst }}</dd>
|
||||
{% endif%}
|
||||
|
||||
{% if object.on_campus is not None %}
|
||||
<dt>{{ object|verbose_name:"on_campus" }}</dt>
|
||||
<dd>{{ object.on_campus|yesno|capfirst }}</dd>
|
||||
{% endif%}
|
||||
|
||||
{% if object.union_account is not None %}
|
||||
<dt>Union Account</dt>
|
||||
<dd>{{ object.union_account|yesno|capfirst }}</dd>
|
||||
|
||||
@@ -78,20 +78,6 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if form.on_campus is not None %}
|
||||
<div class="form-group form-row">
|
||||
<div class="col-sm-10 col-sm-offset-2">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
{% render_field form.on_campus %} {{ form.on_campus.label }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-danger">
|
||||
<span class="fas fa-exclamation"></span> Selecting this option will add <em>all</em> events at this venue to the calendar viewable by UoN Estates.
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if form.union_account is not None %}
|
||||
<div class="form-group form-row">
|
||||
<div class="col-sm-10 col-sm-offset-2">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
{% if now %}
|
||||
<div class="col-sm-12 alert alert-primary rounded-0 mx-auto">
|
||||
{% for event in now %}
|
||||
Event {{ event }} is happening today! <a href="{% url 'event_checkin' event.pk %}" class="btn btn-success btn-sm modal-href align-baseline {% if request.user.current_event %}disabled{%endif%}"><span class="fas fa-user-clock"></span> <span class="d-none d-sm-inline">Check In</span></a><br/>
|
||||
Event {{ event }} is happening now! <a href="{% url 'event_checkin' event.pk %}" class="btn btn-success btn-sm modal-href align-baseline {% if request.user.current_event %}disabled{%endif%}"><span class="fas fa-user-clock"></span> <span class="d-none d-sm-inline">Check In</span></a><br/>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -78,6 +78,11 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr><th colspan="3" class="text-center">{{object}}</th></tr>
|
||||
<tr>
|
||||
<td><ul class="list-unstyled">{% for req in object.started_requirements %}<li>{{ req.item }} {% user_has_qualification u req.item 0 %} {% if request.user.is_supervisor %}<a type="button" class="btn btn-link tn-sm p-0 align-baseline" href="{% url 'remove_requirement' pk=req.pk %}"><span class="fas fa-trash-alt text-danger"></span></a>{%endif%}</li>{% endfor %}</ul></td>
|
||||
<td><ul class="list-unstyled">{% for req in object.complete_requirements %}<li>{{ req.item }} {% user_has_qualification u req.item 1 %} {% if request.user.is_supervisor %}<a type="button" class="btn btn-link tn-sm p-0 align-baseline" href="{% url 'remove_requirement' pk=req.pk %}"><span class="fas fa-trash-alt text-danger"></span></a>{%endif%}</li>{% endfor %}</ul></td>
|
||||
<td><ul class="list-unstyled">{% for req in object.passed_out_requirements %}<li>{{ req.item }} {% user_has_qualification u req.item 2 %} {% if request.user.is_supervisor %}<a type="button" class="btn btn-link tn-sm p-0 align-baseline"" href="{% url 'remove_requirement' pk=req.pk %}" title="Delete requirement"><span class="fas fa-trash-alt text-danger"></span></a>{%endif%}</li>{% endfor %}</ul></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -1,34 +1,33 @@
|
||||
from django.urls import path
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from training.decorators import is_supervisor
|
||||
|
||||
from training import views, models
|
||||
from versioning.views import VersionHistory
|
||||
|
||||
from PyRIGS.decorators import not_estates
|
||||
|
||||
urlpatterns = [
|
||||
path('items/', not_estates()(views.ItemList.as_view()), name='item_list'),
|
||||
path('items/export/', not_estates()(views.ItemListExport.as_view()), name='item_list_export'),
|
||||
path('item/<int:pk>/qualified_users/', not_estates()(views.ItemQualifications.as_view()), name='item_qualification'),
|
||||
path('items/', login_required(views.ItemList.as_view()), name='item_list'),
|
||||
path('items/export/', login_required(views.ItemListExport.as_view()), name='item_list_export'),
|
||||
path('item/<int:pk>/qualified_users/', login_required(views.ItemQualifications.as_view()), name='item_qualification'),
|
||||
|
||||
path('trainee/list/', not_estates()(views.TraineeList.as_view()), name='trainee_list'),
|
||||
path('trainee/<int:pk>/', not_estates()(views.TraineeDetail.as_view()),
|
||||
path('trainee/list/', login_required(views.TraineeList.as_view()), name='trainee_list'),
|
||||
path('trainee/<int:pk>/', login_required(views.TraineeDetail.as_view()),
|
||||
name='trainee_detail'),
|
||||
path('trainee/<int:pk>/history', not_estates()(VersionHistory.as_view()), name='trainee_history', kwargs={'model': models.Trainee, 'app': 'training'}), # Not picked up automatically because proxy model (I think)
|
||||
path('trainee/<int:pk>/history', login_required(VersionHistory.as_view()), name='trainee_history', kwargs={'model': models.Trainee, 'app': 'training'}), # Not picked up automatically because proxy model (I think)
|
||||
path('trainee/<int:pk>/add_qualification/', is_supervisor()(views.AddQualification.as_view()),
|
||||
name='add_qualification'),
|
||||
path('trainee/edit_qualification/<int:pk>/', is_supervisor()(views.EditQualification.as_view()),
|
||||
name='edit_qualification'),
|
||||
|
||||
path('levels/', not_estates()(views.LevelList.as_view()), name='level_list'),
|
||||
path('level/<int:pk>/', not_estates()(views.LevelDetail.as_view()), name='level_detail'),
|
||||
path('level/<int:pk>/user/<int:u>/', not_estates()(views.LevelDetail.as_view()), name='level_detail'),
|
||||
path('levels/', login_required(views.LevelList.as_view()), name='level_list'),
|
||||
path('level/<int:pk>/', login_required(views.LevelDetail.as_view()), name='level_detail'),
|
||||
path('level/<int:pk>/user/<int:u>/', login_required(views.LevelDetail.as_view()), name='level_detail'),
|
||||
path('level/<int:pk>/add_requirement/', is_supervisor()(views.AddLevelRequirement.as_view()), name='add_requirement'),
|
||||
path('level/remove_requirement/<int:pk>/', is_supervisor()(views.RemoveRequirement.as_view()), name='remove_requirement'),
|
||||
|
||||
path('trainee/<int:pk>/level/<int:level_pk>/confirm', is_supervisor()(views.ConfirmLevel.as_view()), name='confirm_level'),
|
||||
path('trainee/<int:pk>/item_record', not_estates()(views.TraineeItemDetail.as_view()), name='trainee_item_detail'),
|
||||
path('trainee/<int:pk>/item_record', login_required(views.TraineeItemDetail.as_view()), name='trainee_item_detail'),
|
||||
|
||||
path('session_log', is_supervisor()(views.SessionLog.as_view()), name='session_log'),
|
||||
]
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.urls import path
|
||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from registration.backends.default.views import RegistrationView
|
||||
|
||||
from PyRIGS.decorators import permission_required_with_403, not_estates
|
||||
from PyRIGS.decorators import permission_required_with_403
|
||||
from users import forms, views
|
||||
|
||||
urlpatterns = [
|
||||
@@ -14,11 +14,11 @@ urlpatterns = [
|
||||
path('user/login/', LoginView.as_view(authentication_form=forms.CheckApprovedForm), name='login'),
|
||||
path('user/login/embed/', xframe_options_exempt(views.LoginEmbed.as_view()), name='login_embed'),
|
||||
# User editing
|
||||
path('user/edit/', not_estates()(views.ProfileUpdateSelf.as_view()),
|
||||
path('user/edit/', login_required(views.ProfileUpdateSelf.as_view()),
|
||||
name='profile_update_self'),
|
||||
path('user/reset_api_key', not_estates()(views.ResetApiKey.as_view(permanent=False)),
|
||||
path('user/reset_api_key', login_required(views.ResetApiKey.as_view(permanent=False)),
|
||||
name='reset_api_key'),
|
||||
path('user/', not_estates()(views.ProfileDetail.as_view()), name='profile_detail'),
|
||||
path('user/', login_required(views.ProfileDetail.as_view()), name='profile_detail'),
|
||||
path('user/<int:pk>/',
|
||||
permission_required_with_403('RIGS.view_profile')(views.ProfileDetail.as_view()),
|
||||
name='profile_detail'),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import logging
|
||||
from diff_match_patch import diff_match_patch
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
@@ -148,9 +147,9 @@ class ModelComparison:
|
||||
|
||||
@cached_property
|
||||
def item_changes(self):
|
||||
from RIGS.models import EventAuthorisation
|
||||
from training.models import TrainingLevelQualification, TrainingItemQualification
|
||||
if self.follow and self.version.object is not None:
|
||||
from RIGS.models import EventAuthorisation
|
||||
from training.models import TrainingLevelQualification, TrainingItemQualification
|
||||
item_type = ContentType.objects.get_for_model(self.version.object)
|
||||
old_item_versions = self.version.parent.revision.version_set.exclude(content_type=item_type).exclude(content_type=ContentType.objects.get_for_model(TrainingItemQualification)) \
|
||||
.exclude(content_type=ContentType.objects.get_for_model(TrainingLevelQualification))
|
||||
@@ -161,14 +160,13 @@ class ModelComparison:
|
||||
# Build some dicts of what we have
|
||||
item_dict = {} # build a list of items, key is the item_pk
|
||||
for version in old_item_versions: # put all the old versions in a list
|
||||
if version._model is None:
|
||||
continue
|
||||
compare = ModelComparison(old=version._object_version.object, **comparisonParams)
|
||||
old = version._object_version.object
|
||||
if old is None:
|
||||
pass
|
||||
compare = ModelComparison(old=old, **comparisonParams)
|
||||
item_dict[version.object_id] = compare
|
||||
|
||||
for version in new_item_versions: # go through the new versions
|
||||
if version._model is None:
|
||||
continue
|
||||
try:
|
||||
compare = item_dict[version.object_id] # see if there's a matching old version
|
||||
compare.new = version._object_version.object # then add the new version to the dictionary
|
||||
|
||||
Reference in New Issue
Block a user