Skip to content

Commit

Permalink
Revert "Allow creation of session and track from abstract"
Browse files Browse the repository at this point in the history
For some reason rejecting an abstract causes "Received data for disabled
field" error.

This reverts commit 98d1ae6.
  • Loading branch information
rppt committed Jul 13, 2024
1 parent afe34dc commit 2869411
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 66 deletions.
10 changes: 3 additions & 7 deletions indico/modules/events/abstracts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ def validate_scale_upper(self, field):
class AbstractJudgmentFormBase(IndicoForm):
"""Form base class for abstract judgment operations."""

_order = ('judgment', 'new_track', 'accepted_track', 'accepted_contrib_type', 'session', 'duplicate_of', 'merged_into',
_order = ('judgment', 'accepted_track', 'accepted_contrib_type', 'session', 'duplicate_of', 'merged_into',
'merge_persons', 'judgment_comment', 'send_notifications')

accepted_track = QuerySelectField(_('Track'), [HiddenUnless('judgment', AbstractAction.accept), HiddenUnless('new_track', False)],
accepted_track = QuerySelectField(_('Track'), [HiddenUnless('judgment', AbstractAction.accept)],
get_label=lambda obj: obj.title_with_group,
allow_blank=True, blank_text=_('Choose a track...'),
description=_('The abstract will be accepted in this track'))
Expand All @@ -219,7 +219,7 @@ class AbstractJudgmentFormBase(IndicoForm):
blank_text=_('You may choose a contribution type...'),
description=_('The abstract will be converted '
'into a contribution of this type'))
session = QuerySelectField(_('Session'), [HiddenUnless('judgment', AbstractAction.accept), HiddenUnless('new_track', False)],
session = QuerySelectField(_('Session'), [HiddenUnless('judgment', AbstractAction.accept)],
get_label='title', allow_blank=True, blank_text=_('You may choose a session...'),
description=_('The generated contribution will be allocated in this session'))
duplicate_of = AbstractField(_('Duplicate of'),
Expand All @@ -237,10 +237,6 @@ class AbstractJudgmentFormBase(IndicoForm):
# TODO: show only if notifications apply?
send_notifications = BooleanField(_('Send notifications to submitter'), default=True)

# TODO: maybe make it widget=SwitchWidget(), for that will need to find
# out why label didn't work
new_track = BooleanField(label=_('Create a track from the abstract'))

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.session.query = Session.query.with_parent(self.event).order_by(Session.title)
Expand Down
9 changes: 1 addition & 8 deletions indico/modules/events/abstracts/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
from indico.modules.events.abstracts.notifications import send_abstract_notifications
from indico.modules.events.abstracts.notifications import send_abstract_comment
from indico.modules.events.contributions.operations import create_contribution_from_abstract, delete_contribution
from indico.modules.events.sessions.operations import create_session_from_abstract
from indico.modules.events.tracks.operations import create_track_from_abstract
from indico.modules.events.util import set_custom_fields
from indico.modules.logs.models.entries import EventLogRealm, LogKind
from indico.modules.logs.util import make_diff_log
Expand Down Expand Up @@ -211,14 +209,9 @@ def judge_abstract(abstract, abstract_data, judgment, judge, contrib_session=Non
abstract.judgment_dt = now_utc()
abstract.judgment_comment = abstract_data['judgment_comment']
log_data = {'Judgment': orig_string(judgment.title)}
print("ops: %s" % abstract_data)
print("ops: %s" % judgment)
if judgment == AbstractAction.accept:
abstract.state = AbstractState.accepted
if abstract_data.get('new_track'):
session = create_session_from_abstract(abstract)
create_track_from_abstract(abstract, session)
elif abstract_data.get('use_review_track') and abstract.reviewed_for_tracks:
if abstract_data.get('use_review_track') and abstract.reviewed_for_tracks:
abstract.accepted_track = next(iter(abstract.reviewed_for_tracks))
else:
abstract.accepted_track = abstract_data.get('accepted_track')
Expand Down
37 changes: 0 additions & 37 deletions indico/modules/events/sessions/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,40 +130,3 @@ def update_session_coordinator_privs(event, data):
log_fields = {priv: orig_string(title) for priv, title in COORDINATOR_PRIV_TITLES.items()}
event.log(EventLogRealm.management, LogKind.change, 'Sessions', 'Coordinator privileges updated',
session.user, data={'Changes': make_diff_log(changes, log_fields)})


def create_session_from_abstract(abstract):
from indico.modules.events.abstracts.settings import abstracts_settings

event = abstract.event
session_data = {
'title': abstract.title,
'description': abstract.description,
}
session = create_session(event, session_data)

emails = [ abstract.submitter.email ]
emails.extend([a.email for a in abstract.primary_authors])
emails.extend([a.email for a in abstract.secondary_authors])

user_perms = []
for e in emails:
user = get_user_by_email(e)
if not user:
continue

user_data = {
'identifier': user.identifier,
'id': user.id,
'familyName': user.last_name,
'firstName': user.first_name,
'name': user.first_name + " " + user.last_name,
'_type': 'Avatar',
}
user_perms.append([user_data, [FULL_ACCESS_PERMISSION]])

update_permissions_from_data(session, user_perms)

db.session.flush()

return session
14 changes: 0 additions & 14 deletions indico/modules/events/tracks/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,3 @@ def update_track_group(track_group, data):
def delete_track_group(track_group):
db.session.delete(track_group)
logger.info('Track group deleted by %r: %r', session.user, track_group)


def create_track_from_abstract(abstract, session):
from indico.modules.events.abstracts.settings import abstracts_settings

event = abstract.event
track_data = {
'title': abstract.title,
'description': abstract.description,
'default_session': session,
}
track = create_track(event, track_data)
db.session.flush()
return session

0 comments on commit 2869411

Please sign in to comment.