Skip to content

Commit

Permalink
Merge pull request #580 from Gig-o-Matic/lockable_plans
Browse files Browse the repository at this point in the history
Lockable plans
  • Loading branch information
bklang authored Feb 22, 2025
2 parents b8e22ab + ea5214a commit 2251e8a
Show file tree
Hide file tree
Showing 17 changed files with 1,037 additions and 731 deletions.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
version: "3.8"
services:
web:
build: .
Expand Down
26 changes: 21 additions & 5 deletions gig/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def decorated(request, pk, *args, **kw):
@login_required
@plan_editor_required
def update_plan(request, plan, val):
if plan.gig.plans_locked:
return HttpResponseForbidden()
plan.status = val
plan.save()
return render(request, 'gig/plan_icon.html', {'plan_value': val})
Expand Down Expand Up @@ -127,7 +129,7 @@ def generate_changes(latest, previous):
# changes.append((_('Set Time'), *date_diff(latest.setdate, previous.setdate)))
# if 'enddate' in diff.changed_fields:
# changes.append((_('End Time'), *date_diff(latest.enddate, previous.enddate)))

check = [x in diff.changed_fields for x in ['is_full_day', 'date', 'setdate', 'enddate', 'datenotes']]
if True in check:
changes.append((_('Date/Time'), _('(See below.)'), None))
Expand All @@ -143,7 +145,7 @@ def generate_changes(latest, previous):

if 'setlist' in diff.changed_fields:
changes.append((_('Set List'), None, None))

if 'dress' in diff.changed_fields:
changes.append((_('What To Wear'), _('(See below.)'), None))

Expand Down Expand Up @@ -203,6 +205,20 @@ def notify_new_gig(gig, created, dates=None):
async_task('gig.helpers.send_email_from_gig', gig,
'email/new_gig.md' if created else 'email/edited_gig.md')

@login_required
@band_editor_required
def gig_lock_plans(request, gig):
gig.plans_locked = True
gig.save()
return redirect('gig-detail', pk=gig.id)

@login_required
@band_editor_required
def gig_unlock_plans(request, gig):
gig.plans_locked = False
gig.save()
return redirect('gig-detail', pk=gig.id)

@login_required
@band_editor_required
def gig_untrash(request, gig):
Expand Down Expand Up @@ -246,7 +262,7 @@ def create_gig_series(the_gig, number_to_copy, period):
delta = timedelta(weeks=1)
else:
day_of_month = last_date.day

set_delta = (the_gig.setdate - the_gig.date) if the_gig.setdate else None
end_delta = (the_gig.enddate - the_gig.date) if the_gig.enddate else None

Expand All @@ -265,7 +281,7 @@ def create_gig_series(the_gig, number_to_copy, period):
last_date = last_date.replace(month=mo, day=min(calendar.monthrange(yr,mo)[1], day_of_month), year=yr)

the_gig.date = last_date

if set_delta is not None:
the_gig.setdate = the_gig.date + set_delta

Expand All @@ -278,6 +294,6 @@ def create_gig_series(the_gig, number_to_copy, period):
the_gig.cal_feed_id = uuid.uuid4()
the_gig.save()
the_dates.append(the_gig.date)

# return the list of dates for all the gigs
return the_dates
23 changes: 23 additions & 0 deletions gig/migrations/0021_gig_plans_locked_historicalgig_plans_locked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.17 on 2025-02-16 22:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('gig', '0020_auto_20240325_1946'),
]

operations = [
migrations.AddField(
model_name='gig',
name='plans_locked',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='historicalgig',
name='plans_locked',
field=models.BooleanField(default=False),
),
]
14 changes: 14 additions & 0 deletions gig/migrations/0025_merge_20250222_1612.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.2.17 on 2025-02-22 16:12

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('gig', '0021_gig_plans_locked_historicalgig_plans_locked'),
('gig', '0024_change_dates_by_band_timezone'),
]

operations = [
]
16 changes: 6 additions & 10 deletions gig/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def future_plans(self, member):

# find plans that are for this member that are not trashed or archived
possible = super().get_queryset().filter(assoc__member=member,
assoc__status=AssocStatusChoices.CONFIRMED,
gig__trashed_date__isnull=True,
gig__is_archived=False,
)
assoc__status=AssocStatusChoices.CONFIRMED,
gig__trashed_date__isnull=True,
gig__is_archived=False,
)
# find plans for gigs that haven't ended yet
possible = possible.filter((Q(gig__is_full_day=True) & Q(gig__date__gte=yesterday_for_user)) |
(Q(gig__enddate=None) & Q(gig__date__gte=recent_for_user)) |
Expand Down Expand Up @@ -192,12 +192,8 @@ class Gig(AbstractEvent):
leader = models.ForeignKey('member.Member', blank=True, null=True, related_name="leader_gigs", on_delete=models.SET_NULL)
leader_text = models.TextField(null=True, blank=True)

# todo manage these
# trueenddate = ndb.ComputedProperty(lambda self: self.enddate if self.enddate else self.date)
# sorttime = ndb.IntegerProperty( default=None )

# todo what's this?
# comment_id = ndb.TextProperty( default = None)
# Flag whether band members can change their plans
plans_locked = models.BooleanField(default=False)

rss_description = models.TextField(null=True, blank=True)

Expand Down
2 changes: 2 additions & 0 deletions gig/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
path('<int:pk>/untrash', helpers.gig_untrash, name='gig-untrash'),
path('<int:pk>/archive', helpers.gig_archive, name='gig-archive'),
path('<int:pk>/remind', helpers.gig_remind, name='gig-remind'),
path('<int:pk>/lock_plans', helpers.gig_lock_plans, name='gig-lock-plans'),
path('<int:pk>/unlock_plans', helpers.gig_unlock_plans, name='gig-unlock-plans'),
path('<int:pk>/printallplans', views.PrintPlansView.as_view(), {'all':True}, name='gig-print-all-plans'),
path('<int:pk>/printconfirmedplans', views.PrintPlansView.as_view(), {'all':False}, name='gig-print-confirmed-plans'),
path('<int:pk>/printsetlist', views.PrintSetlistView.as_view(), name='gig-print-setlist'),
Expand Down
Loading

0 comments on commit 2251e8a

Please sign in to comment.