Skip to content

Commit 152dc25

Browse files
committed
Port some utilities of ietfworkflows
- Legacy-Id: 3406
1 parent b4c7574 commit 152dc25

3 files changed

Lines changed: 35 additions & 11 deletions

File tree

ietf/ietfworkflows/accounts.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
from django.conf import settings
2+
13
from ietf.ietfworkflows.streams import get_streamed_draft
4+
from redesign.group.models import Role
25

36

47
def get_person_for_user(user):
@@ -17,10 +20,16 @@ def is_secretariat(user):
1720
def is_wgchair(person):
1821
return bool(person.wgchair_set.all())
1922

23+
def is_wgchairREDESIGN(person):
24+
return bool(Role.objects.filter(name="chair", group__type="wg", group__state="active", email__person=person))
25+
2026

2127
def is_wgdelegate(person):
2228
return bool(person.wgdelegate_set.all())
2329

30+
def is_delegateREDESIGN(person):
31+
return bool(Role.objects.filter(name="delegate", group__type="wg", group__state="active", email__person=person))
32+
2433

2534
def is_chair_of_draft(user, draft):
2635
person = get_person_for_user(user)
@@ -34,6 +43,18 @@ def is_chair_of_draft(user, draft):
3443
return False
3544
return bool(group.chairs().filter(person=person).count())
3645

46+
def is_chair_of_draftREDESIGN(user, draft):
47+
if not user.is_authenticated() or not user.get_profile() or not draft.group:
48+
return False
49+
50+
return bool(Role.objects.filter(name="chair", group=draft.group, email__person=user.get_profile()))
51+
52+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
53+
from ietf.wgchairs.accounts import is_secretariat, get_person_for_user
54+
is_delegate = is_delegateREDESIGN
55+
is_wgchair = is_wgchairREDESIGN
56+
is_chair_of_draft = is_chair_of_draftREDESIGN
57+
3758

3859
def can_edit_state(user, draft):
3960
streamed = get_streamed_draft(draft)

ietf/ietfworkflows/templatetags/ietf_streams.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django import template
2+
from django.conf import settings
23

34
from ietf.idrfc.idrfc_wrapper import IdRfcWrapper, IdWrapper
45
from ietf.ietfworkflows.utils import (get_workflow_for_draft,
@@ -14,8 +15,8 @@
1415

1516
@register.inclusion_tag('ietfworkflows/stream_state.html', takes_context=True)
1617
def stream_state(context, doc):
17-
from django.conf import settings
18-
return settings.TEMPLATE_STRING_IF_INVALID # FIXME: temporary work-around
18+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
19+
return settings.TEMPLATE_STRING_IF_INVALID # FIXME: temporary work-around
1920
request = context.get('request', None)
2021
data = {}
2122
stream = get_stream_from_wrapper(doc)
@@ -54,7 +55,8 @@ def workflow_history_entry(context, entry):
5455

5556
@register.inclusion_tag('ietfworkflows/edit_actions.html', takes_context=True)
5657
def edit_actions(context, wrapper):
57-
return None # FIXME: temporary work-around
58+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
59+
return settings.TEMPLATE_STRING_IF_INVALID # FIXME: temporary work-around
5860

5961
request = context.get('request', None)
6062
user = request and request.user

ietf/ietfworkflows/utils.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,15 @@ def update_stream(obj, comment, person, to_stream, extra_notify=[]):
284284

285285

286286
def get_full_info_for_draft(draft):
287-
return dict(# FIXME: temporary work-around
288-
streamed=settings.TEMPLATE_STRING_IF_INVALID,
289-
stream=settings.TEMPLATE_STRING_IF_INVALID,
290-
workflow=settings.TEMPLATE_STRING_IF_INVALID,
291-
tags=[settings.TEMPLATE_STRING_IF_INVALID],
292-
state=settings.TEMPLATE_STRING_IF_INVALID,
293-
shepherd=draft.shepherd,
294-
)
287+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
288+
return dict(# FIXME: temporary work-around
289+
streamed=settings.TEMPLATE_STRING_IF_INVALID,
290+
stream=settings.TEMPLATE_STRING_IF_INVALID,
291+
workflow=settings.TEMPLATE_STRING_IF_INVALID,
292+
tags=[settings.TEMPLATE_STRING_IF_INVALID],
293+
state=settings.TEMPLATE_STRING_IF_INVALID,
294+
shepherd=draft.shepherd,
295+
)
295296

296297
return dict(
297298
streamed=get_streamed_draft(draft),

0 commit comments

Comments
 (0)