Skip to content

Commit

Permalink
Merge pull request #799 from WPI-LNL/793-add-lnl-contact-field-to-events
Browse files Browse the repository at this point in the history
Add lnl contact field
  • Loading branch information
pfrunzio committed Aug 31, 2023
2 parents 26c197b + e8a8f39 commit 1371808
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 4 deletions.
25 changes: 25 additions & 0 deletions accounts/migrations/0010_auto_20230827_1351.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.14 on 2023-08-27 17:51

import django.core.validators
from django.db import migrations, models
import multiselectfield.db.fields


class Migration(migrations.Migration):

dependencies = [
('accounts', '0009_officer_info'),
]

operations = [
migrations.AlterField(
model_name='user',
name='class_year',
field=models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1962), django.core.validators.MaxValueValidator(2029)]),
),
migrations.AlterField(
model_name='userpreferences',
name='event_edited_field_subscriptions',
field=multiselectfield.db.fields.MultiSelectField(choices=[('event_name', 'Event name'), ('description', 'Description'), ('location', 'Location'), ('contact', 'Contact'), ('lnl_contact', 'LNL 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=149),
),
]
1 change: 1 addition & 0 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class PhoneVerificationCode(Model):
('description', 'Description'),
('location', 'Location'),
('contact', 'Contact'),
('lnl_contact', 'LNL contact'),
('billing_org', 'Billing org'),
('datetime_setup_complete', 'Datetime setup complete'),
('datetime_start', 'Datetime start'),
Expand Down
2 changes: 1 addition & 1 deletion accounts/perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class EventUserPermLogic(AssocUsersCustomPermissionLogic):
field_name = ['submitter__contact', 'submitter__crew_chief', 'submitter__ccinstances__crew_chief',
'event__submitted_by', 'event__crew_chief', 'event__ccinstances__crew_chief',
'event__submitted_by', 'event__lnl_contact', 'event__crew_chief', 'event__ccinstances__crew_chief',
'ccinstances__event__submitted_by', 'ccinstances__event__contact', 'ccinstances__event__crew_chief',
'crewchiefx__contact', 'crewchiefx__submitted_by', 'crewchiefx__ccinstances__crew_chief',
'contact__ccinstances__crew_chief', 'contact__crew_chief', 'contact__submitted_by']
Expand Down
2 changes: 1 addition & 1 deletion events/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class BaseEventAdmin(VersionAdmin, PolymorphicParentModelAdmin):
'fields': ('submitted_by', 'submitted_ip', 'submitted_on')
}),
('Event And Contact Information', {
'fields': ('event_name', 'description', 'internal_notes', 'contact', 'org', 'billing_org')
'fields': ('event_name', 'lnl_contact', 'description', 'internal_notes', 'contact', 'org', 'billing_org')
}),
('Scheduling & Location', {
'fields': ('datetime_setup_complete', 'datetime_start', 'datetime_end',
Expand Down
18 changes: 16 additions & 2 deletions events/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def __init__(self, request_user, *args, **kwargs):
'Name And Location',
'event_name',
'location',
'lnl_contact',
Field('description'),
DynamicFieldContainer('internal_notes'),
'billed_in_bulk',
Expand Down Expand Up @@ -532,9 +533,14 @@ def __init__(self):
enable=('sensitive', 'test_event')
)

change_lnl_contact = FieldAccessLevel(
lambda user, instance: user.has_perm('events.edit_event_lnl_contact', instance),
enable=('lnl_contact')
)

class Meta:
model = Event
fields = ('event_name', 'location', 'description', 'internal_notes', 'billing_org', 'billed_in_bulk', 'contact',
fields = ('event_name', 'location', 'lnl_contact', 'description', 'internal_notes', 'billing_org', 'billed_in_bulk', 'contact',
'org', 'datetime_setup_complete', 'datetime_start', 'datetime_end', 'lighting', 'lighting_reqs',
'sound', 'sound_reqs', 'projection', 'proj_reqs', 'otherservices', 'otherservice_reqs', 'sensitive',
'test_event')
Expand All @@ -553,6 +559,7 @@ class Meta:
group_label=lambda group: group.name,
)
contact = AutoCompleteSelectField('Users', required=False)
lnl_contact = AutoCompleteSelectField('Members', required=False)
org = CustomAutoCompleteSelectMultipleField('Orgs', required=False, label="Client(s)")
billing_org = AutoCompleteSelectField('Orgs', required=False, label="Client to bill")
datetime_setup_complete = forms.SplitDateTimeField(initial=timezone.now, label="Setup Completed")
Expand All @@ -569,6 +576,7 @@ def __init__(self, request_user, *args, **kwargs):
'Name And Location',
'event_name',
'location',
'lnl_contact',
'reference_code',
Field('description'),
DynamicFieldContainer('internal_notes'),
Expand Down Expand Up @@ -669,6 +677,11 @@ def __init__(self):
enable=('sensitive', 'test_event')
)

change_lnl_contact = FieldAccessLevel(
lambda user, instance: user.has_perm('events.edit_event_lnl_contact', instance),
enable=('lnl_contact')
)

change_entered_into_workday = FieldAccessLevel(
lambda user, instance: user.has_perm('events.bill_event', instance),
enable=('entered_into_workday',)
Expand All @@ -691,7 +704,7 @@ def __init__(self):

class Meta:
model = Event2019
fields = ('event_name', 'location', 'description', 'internal_notes', 'billing_org',
fields = ('event_name', 'location', 'lnl_contact', 'description', 'internal_notes', 'billing_org',
'billed_in_bulk', 'contact', 'org', 'datetime_setup_complete', 'datetime_start',
'datetime_end', 'sensitive', 'test_event',
'entered_into_workday', 'send_survey', 'max_crew','cancelled_reason',
Expand All @@ -708,6 +721,7 @@ class Meta:
group_label=lambda group: group.name,
)
contact = AutoCompleteSelectField('Users', required=False)
lnl_contact = AutoCompleteSelectField('Members', label="LNL Contact (PM)", required=False)
org = CustomAutoCompleteSelectMultipleField('Orgs', required=False, label="Client(s)")
billing_org = AutoCompleteSelectField('Orgs', required=False, label="Client to bill")
datetime_setup_complete = forms.SplitDateTimeField(initial=timezone.now, label="Setup Completed")
Expand Down
21 changes: 21 additions & 0 deletions events/migrations/0009_baseevent_lnl_contact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.1.14 on 2023-08-27 17:51

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('events', '0008_auto_20220210_0751'),
]

operations = [
migrations.AddField(
model_name='baseevent',
name='lnl_contact',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='lnl_contact', to=settings.AUTH_USER_MODEL, verbose_name='LNL Contact'),
),
]
17 changes: 17 additions & 0 deletions events/migrations/0010_auto_20230827_1406.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.1.14 on 2023-08-27 18:06

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('events', '0009_baseevent_lnl_contact'),
]

operations = [
migrations.AlterModelOptions(
name='baseevent',
options={'ordering': ['-datetime_start'], 'permissions': (('view_events', "Show an event that isn't hidden"), ('add_raw_event', 'Use the editor to create an event'), ('event_images', 'Upload images to an event'), ('view_hidden_event', 'Show hidden events'), ('cancel_event', 'Declare an event to be cancelled'), ('event_attachments', 'Upload attachments to an event'), ('edit_event_times', 'Modify the dates for an event'), ('add_event_report', 'Add reports about the event'), ('edit_event_fund', 'Change where money for an event comes from'), ('view_event_billing', 'See financial info for event'), ('view_event_reports', 'See reports for event'), ('edit_event_text', 'Update any event descriptions'), ('adjust_event_owner', 'Change the event contact and organization'), ('edit_event_hours', 'Modify the time sheets'), ('edit_event_flags', 'Add flags to an event'), ('edit_event_lnl_contact', 'Change the LNL contact for an event'), ('event_view_sensitive', 'Show internal notes and other metadata marked as not public'), ('approve_event', 'Accept an event'), ('decline_event', 'Decline an event'), ('can_chief_event', 'Can crew chief an event'), ('review_event', 'Review an event for billing'), ('adjust_event_charges', 'Add charges and change event type'), ('bill_event', 'Send bills and mark event paid'), ('close_event', 'Lock an event after everything is done.'), ('view_test_event', 'Show events for testing'), ('event_view_granular', 'See debug data like ip addresses'), ('event_view_debug', 'See debug events'), ('reopen_event', 'Reopen a closed, declined, or cancelled event')), 'verbose_name': 'Event'},
),
]
2 changes: 2 additions & 0 deletions events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class BaseEvent(PolymorphicModel):
description = models.TextField(null=True, blank=True)
location = models.ForeignKey('Location', on_delete=models.PROTECT)
contact = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, blank=True, verbose_name="Contact", related_name="contact")
lnl_contact = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, blank=True, verbose_name="LNL Contact", related_name="lnl_contact")
org = models.ManyToManyField('Organization', blank=True, verbose_name="Client", related_name='events')
billing_org = models.ForeignKey('Organization', on_delete=models.PROTECT, null=True, blank=True, related_name="billedevents")

Expand Down Expand Up @@ -457,6 +458,7 @@ class Meta:
("adjust_event_owner", "Change the event contact and organization"),
("edit_event_hours", "Modify the time sheets"),
('edit_event_flags', 'Add flags to an event'),
('edit_event_lnl_contact', 'Change the LNL contact for an event'),
("event_view_sensitive", "Show internal notes and other metadata marked as not public"),
("approve_event", "Accept an event"),
("decline_event", "Decline an event"),
Expand Down
5 changes: 5 additions & 0 deletions fixtures/groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@
"events",
"baseevent"
],
[
"edit_event_lnl_contact",
"events",
"baseevent"
],
[
"edit_event_fund",
"events",
Expand Down
6 changes: 6 additions & 0 deletions site_tmpl/uglydetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ <h3 id="reopenModalLabel">Confirm Reopen Event</h3>
<div class="tab-content">
<div id="home" class="tab-pane active">
<table class="table">
<tr>
<th>LNL Contact (PM)</th>
<td>{% if event.lnl_contact %}
<a href="{% url "accounts:detail" event.lnl_contact.id %}">{{ event.lnl_contact.get_full_name }}</a>
{% else %}{{ event.lnl_contact }} {% endif %}</td>
</tr>
<tr>
<th>Posted Description</th>
<td>{{ event.description|markdown }}</td>
Expand Down

0 comments on commit 1371808

Please sign in to comment.