Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "finished" CfP state to "finalised" #1358

Merged
merged 3 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions apps/admin/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def get_users(dest: str) -> list[User]:
elif dest == "purchasers":
query = query.join(User.payments).filter(Payment.state == "paid")
elif dest == "cfp":
query = query.join(User.proposals).filter(
Proposal.state.in_(("accepted", "finished"))
)
query = query.join(User.proposals).filter(Proposal.is_accepted)
elif dest == "villages":
query = query.join(User.village_membership).filter(VillageMember.admin)

Expand Down
2 changes: 1 addition & 1 deletion apps/api/installations.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Installations(Resource):
def get(self):
result = []
proposals = InstallationProposal.query.filter(
InstallationProposal.state.in_(["accepted", "finished"])
InstallationProposal.is_accepted
).all()
for proposal in proposals:
result.append(render_installation(proposal))
Expand Down
4 changes: 2 additions & 2 deletions apps/base/dev/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def fake_proposal(fake, reviewers):
"anon-blocked": 0.05,
"new": 0.05,
"reviewed": 0.2,
"finished": 0.3,
"finalised": 0.3,
}

cfp.state = random_state(states)
Expand All @@ -100,7 +100,7 @@ def fake_proposal(fake, reviewers):
if vote.state in ("voted", "stale", "resolved"):
vote.vote = random.randint(0, 2)

if cfp.state == "finished" and type(cfp) is TalkProposal:
if cfp.state == "finalised" and type(cfp) is TalkProposal:
cfp.available_times = "fri_10_13,fri_13_16,fri_16_20,sat_10_13,sat_13_16,sat_16_20,sun_10_13,sun_13_16,sun_16_20"

if type(cfp) in (WorkshopProposal, YouthWorkshopProposal):
Expand Down
2 changes: 1 addition & 1 deletion apps/cfp/schedule_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def apply_potential_schedule(email, type):
| (Proposal.potential_time != None) # noqa: E711
)
.filter(Proposal.scheduled_duration.isnot(None))
.filter(Proposal.state.in_(["accepted", "finished"]))
.filter(Proposal.is_accepted)
.all()
)

Expand Down
4 changes: 2 additions & 2 deletions apps/cfp/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Scheduler(object):
def set_rough_durations(self):
proposals = (
Proposal.query.filter_by(scheduled_duration=None, type="talk")
.filter(Proposal.state.in_(["accepted", "finished"]))
.filter(Proposal.is_accepted)
.all()
)

Expand All @@ -49,7 +49,7 @@ def get_scheduler_data(
):
proposals = (
Proposal.query.filter(Proposal.scheduled_duration.isnot(None))
.filter(Proposal.state.in_(["finished", "accepted"]))
.filter(Proposal.is_accepted)
.filter(Proposal.type.in_(type))
.order_by(Proposal.favourite_count.desc())
.all()
Expand Down
2 changes: 1 addition & 1 deletion apps/cfp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def email_check():
"""Email speakers about their slot"""
proposals = (
Proposal.query.filter(Proposal.scheduled_duration.isnot(None))
.filter(Proposal.state.in_(["accepted", "finished"]))
.filter(Proposal.is_accepted)
.filter(Proposal.type.in_(["talk", "workshop", "youthworkshop", "performance"]))
.all()
)
Expand Down
11 changes: 5 additions & 6 deletions apps/cfp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class LightningTalkProposalForm(ProposalForm):

def set_session_choices(self, remaining_lightning_slots):
self.session.choices = []
for (day_id, day_count) in remaining_lightning_slots.items():
for day_id, day_count in remaining_lightning_slots.items():
if day_count <= 0:
continue
self.session.choices.append(
Expand Down Expand Up @@ -533,7 +533,6 @@ def withdraw_proposal(proposal_id):
form = WithdrawalForm()
if form.validate_on_submit():
if form.confirm_withdrawal.data:

app.logger.info("Proposal %s is being withdrawn.", proposal_id)
proposal.set_state("withdrawn")

Expand Down Expand Up @@ -653,7 +652,7 @@ def finalise_proposal(proposal_id):
if proposal.user != current_user:
abort(404)

if proposal.state not in ("accepted", "finished"):
if not proposal.is_accepted:
return redirect(url_for(".edit_proposal", proposal_id=proposal_id))

# This is horrendous, but is a lot cleaner than having shitloads of classes and fields
Expand Down Expand Up @@ -698,10 +697,10 @@ class F(FinaliseForm):
proposal.published_participant_equipment = form.participant_equipment.data

proposal.available_times = form.get_availability_json()
proposal.set_state("finished")
proposal.set_state("finalised")

db.session.commit()
app.logger.info("Finished proposal %s", proposal_id)
app.logger.info("Finalised proposal %s", proposal_id)
flash("Thank you for finalising your details!")

return redirect(url_for(".edit_proposal", proposal_id=proposal_id))
Expand All @@ -710,7 +709,7 @@ class F(FinaliseForm):
# Don't overwrite user submitted data
pass

elif proposal.state == "finished":
elif proposal.state == "finalised":
if proposal.published_names:
form.name.data = proposal.published_names
else:
Expand Down
19 changes: 7 additions & 12 deletions apps/cfp_review/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def close_round():
if form.validate_on_submit():
if form.confirm.data:
min_votes = session["min_votes"]
for (prop, vote_count) in proposals:
for prop, vote_count in proposals:
if vote_count >= min_votes and prop.state != "reviewed":
prop.set_state("reviewed")

Expand All @@ -896,7 +896,7 @@ def close_round():
# Find proposals where the submitter has already had an accepted proposal
# or another proposal in this list
duplicates = {}
for (prop, _) in proposals:
for prop, _ in proposals:
if prop.user.proposals.count() > 1:
# Only add each proposal once
if prop.user not in duplicates:
Expand Down Expand Up @@ -937,8 +937,7 @@ def rank():
if form.confirm.data:
min_score = session["min_score"]
count = 0
for (prop, score) in scored_proposals:

for prop, score in scored_proposals:
if score >= min_score:
count += 1
prop.set_state("accepted")
Expand Down Expand Up @@ -975,19 +974,15 @@ def rank():
elif form.cancel.data and "min_score" in session:
del session["min_score"]

accepted_proposals = Proposal.query.filter(
Proposal.state.in_(["accepted", "finished"])
)
accepted_proposals = Proposal.query.filter(Proposal.is_accepted)
accepted_counts = defaultdict(int)
for proposal in accepted_proposals:
accepted_counts[proposal.type] += 1

allocated_minutes = defaultdict(int)
unknown_lengths = defaultdict(int)

accepted_proposals = Proposal.query.filter(
Proposal.state.in_(["accepted", "finished"])
).all()
accepted_proposals = Proposal.query.filter(Proposal.is_accepted).all()
for proposal in accepted_proposals:
length = None
if proposal.scheduled_duration:
Expand Down Expand Up @@ -1060,7 +1055,7 @@ def potential_schedule_changes():
def scheduler():
proposals = (
Proposal.query.filter(Proposal.scheduled_duration.isnot(None))
.filter(Proposal.state.in_(["finished", "accepted"]))
.filter(Proposal.state.is_accepted)
.filter(Proposal.type.in_(["talk", "workshop", "youthworkshop", "performance"]))
.all()
)
Expand Down Expand Up @@ -1168,7 +1163,7 @@ def clashfinder():

clashes = []
offset = 0
for ((id1, id2), count) in popularity.most_common()[:1000]:
for (id1, id2), count in popularity.most_common()[:1000]:
offset += 1
prop1 = Proposal.query.get(id1)
prop2 = Proposal.query.get(id2)
Expand Down
3 changes: 1 addition & 2 deletions apps/cfp_review/venues.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def edit_venue(venue_id):
if form.validate_on_submit():
if form.delete.data:
scheduled_content = Proposal.query.filter(
Proposal.scheduled_venue_id == venue.id,
Proposal.state.in_(["accepted", "finished"]),
Proposal.scheduled_venue_id == venue.id, Proposal.is_accepted
).count()

if scheduled_content > 0:
Expand Down
4 changes: 2 additions & 2 deletions apps/schedule/attendee_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def attendee_content():
or_(
Proposal.user_scheduled is True, Proposal.scheduled_venue_id.in_(venue_ids)
),
Proposal.state.in_(["accepted", "finished"]),
Proposal.is_accepted,
).all()

form = ContentForm()
Expand All @@ -129,7 +129,7 @@ def attendee_content():
proposal = PYTHON_CFP_TYPES[form.type.data]()
proposal.user_id = current_user.id
proposal.user_scheduled = True
proposal.state = "finished"
proposal.state = "finalised"
populate(proposal, form)

conflicts = proposal.get_conflicting_content()
Expand Down
8 changes: 4 additions & 4 deletions apps/schedule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def schedule_current():
def line_up():
proposals = Proposal.query.filter(
Proposal.scheduled_duration.isnot(None),
Proposal.state.in_(["accepted", "finished"]),
Proposal.is_accepted,
Proposal.type.in_(["talk", "workshop", "youthworkshop", "performance"]),
Proposal.hide_from_schedule.isnot(True),
).all()
Expand Down Expand Up @@ -172,7 +172,7 @@ def item(year, proposal_id, slug=None):
def item_current(year, proposal_id, slug=None):
"""Display a detail page for a talk from the current event"""
proposal = Proposal.query.get_or_404(proposal_id)
if proposal.state not in ("accepted", "finished") or proposal.hide_from_schedule:
if not proposal.is_accepted or proposal.hide_from_schedule:
abort(404)

if not current_user.is_anonymous:
Expand Down Expand Up @@ -308,7 +308,7 @@ def herald_message(message, proposal):
Proposal.query.join(Venue, Venue.id == Proposal.scheduled_venue_id)
.filter(
Venue.name == venue_name,
Proposal.state.in_(["accepted", "finished"]),
Proposal.is_accepted,
Proposal.scheduled_time > pendulum.now(event_tz),
Proposal.scheduled_duration.isnot(None),
Proposal.hide_from_schedule.isnot(True),
Expand Down Expand Up @@ -394,7 +394,7 @@ def greenroom_message(message):
upcoming = (
Proposal.query.filter(
Proposal.type.in_(["talk", "workshop", "youthworkshop", "performance"]),
Proposal.state.in_(["accepted", "finished"]),
Proposal.is_accepted,
Proposal.scheduled_time > pendulum.now(event_tz),
Proposal.scheduled_duration.isnot(None),
Proposal.hide_from_schedule.isnot(True),
Expand Down
2 changes: 1 addition & 1 deletion apps/schedule/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _get_scheduled_proposals(filter_obj={}, override_user=None):
external_favourites = [f.id for f in user.calendar_favourites]

schedule = Proposal.query.filter(
Proposal.state.in_(["accepted", "finished"]),
Proposal.is_accepted,
Proposal.scheduled_time.isnot(None),
Proposal.scheduled_venue_id.isnot(None),
Proposal.scheduled_duration.isnot(None),
Expand Down
4 changes: 2 additions & 2 deletions apps/schedule/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def schedule_frab(year):

schedule = (
Proposal.query.filter(
Proposal.state.in_(["accepted", "finished"]),
Proposal.is_accepted,
Proposal.scheduled_time.isnot(None),
Proposal.scheduled_venue_id.isnot(None),
Proposal.scheduled_duration.isnot(None),
Expand Down Expand Up @@ -169,7 +169,7 @@ def item_json(year, proposal_id, slug=None):
if year != event_year():
abort(404)
proposal = Proposal.query.get_or_404(proposal_id)
if proposal.state not in ("accepted", "finished"):
if not proposal.is_accepted:
abort(404)

if not current_user.is_anonymous:
Expand Down
2 changes: 1 addition & 1 deletion apps/volunteer/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run(self):

events = (
Proposal.query.join(Venue, Proposal.scheduled_venue_id == Venue.id)
.filter(Venue.name == venue.name, Proposal.state == "finished")
.filter(Venue.name == venue.name, Proposal.state == "finalised")
.all()
)
for e in events:
Expand Down
16 changes: 9 additions & 7 deletions models/cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"anon-blocked": ["accepted", "rejected", "withdrawn", "reviewed", "edit"],
"reviewed": ["accepted", "rejected", "withdrawn", "edit", "anonymised"],
"manual-review": ["accepted", "rejected", "withdrawn", "edit"],
"accepted": ["accepted", "rejected", "withdrawn", "finished"],
"finished": ["rejected", "withdrawn", "finished"],
"accepted": ["accepted", "rejected", "withdrawn", "finalised"],
"finalised": ["rejected", "withdrawn", "finalised"],
"withdrawn": ["accepted", "rejected", "withdrawn", "edit"],
}

Expand All @@ -69,7 +69,7 @@
"manual-review",
"reviewed",
"accepted",
"finished",
"finalised",
"withdrawn",
]

Expand Down Expand Up @@ -363,6 +363,8 @@ class Proposal(BaseModel):
state = db.Column(db.String, nullable=False, default="new")
type = db.Column(db.String, nullable=False) # talk, workshop or installation

is_accepted = column_property(state.in_(["accepted", "finalised"]))

# Core information
title = db.Column(db.String, nullable=False)
description = db.Column(db.String, nullable=False)
Expand Down Expand Up @@ -525,16 +527,16 @@ def get_export_data(cls):
Venue.name,
)
accepted_proposals = (
proposals.filter(cls.state.in_(["accepted", "finished"]))
proposals.filter(cls.is_accepted)
.outerjoin(cls.scheduled_venue)
.join(cls.user)
.add_columns(*accepted_columns)
)

other_proposals = proposals.filter(~cls.state.in_(["accepted", "finished"]))
other_proposals = proposals.filter(~cls.is_accepted)

user_favourites = (
cls.query.filter(cls.state.in_(["accepted", "finished"]))
cls.query.filter(cls.is_accepted)
.join(cls.favourites)
.with_entities(User.id.label("user_id"), cls.id)
.order_by(User.id)
Expand All @@ -556,7 +558,7 @@ def get_export_data(cls):
Venue.name.label("venue"),
)
accepted_public = (
cls.query.filter(cls.state.in_(["accepted", "finished"]))
cls.query.filter(cls.is_accepted)
.outerjoin(cls.scheduled_venue)
.with_entities(*public_columns)
)
Expand Down
4 changes: 2 additions & 2 deletions models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def get_export_data(cls):
u.email
for u in User.query.join(
Proposal, Proposal.user_id == User.id
).filter(Proposal.state.in_(("accepted", "finished")))
).filter(Proposal.is_accepted)
],
},
}
Expand Down Expand Up @@ -398,7 +398,7 @@ def get_by_bar_training_token(cls, code) -> User:
@property
def is_cfp_accepted(self):
for proposal in self.proposals:
if proposal.state in {"accepted", "finished"}:
if proposal.is_accepted:
return True
return False

Expand Down
4 changes: 2 additions & 2 deletions templates/cfp/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h2>Proposal Detail</h2>
{% include "cfp/edit-form.html" %}
{% else %}
<div class="well"><div class="row">
{% if feature_enabled('CFP_FINALISE') and proposal.state in ['accepted', 'finished'] %}
{% if feature_enabled('CFP_FINALISE') and proposal.is_accepted %}
<div class="col-md-12">
Your {{ proposal.human_type }} has been accepted! If you haven't already, please
<a href="{{ url_for('.finalise_proposal', proposal_id=proposal.id ) }}">finalise your details</a>.
Expand All @@ -42,7 +42,7 @@ <h2>Proposal Detail</h2>
<div class="col-md-6">
<legend>About your {{proposal.human_type}}</legend>
<dl class="dl-vertical">
{% if feature_enabled('CFP_FINALISE') and proposal.state in ['finished'] %}
{% if feature_enabled('CFP_FINALISE') and proposal.state == 'finalised' %}
<dt>Names</dt><dd>{{proposal.published_names}}</dd>
<dt>Pronouns</dt><dd>{{proposal.published_pronouns}}</dd>
<dt>Title</dt><dd>{{proposal.published_title}}</dd>
Expand Down
Loading
Loading