old_contents: from django.utils.text import slugify
  
  from guardian.shortcuts import get_perms
  
  
  def build_org_group_name(org_name, group):
      '''Returns org group name in the form of <ORGNAME>_ORG_<GROUP>'''
      return f'{slugify({org_name})}_ORG_{group}'.upper()
  
  
  def build_study_group_name(org_name, study_name, study_pk, group):
      '''Returns org group name in the form of <ORGNAME>_ORG_<GROUP>'''
      return f'{slugify({org_name})}_{slugify({study_name})}_{study_pk}_STUDY_{group}'.upper()
  
  status_tooltip_text = {
      'created': 'Study has not been submitted for approval',
      'active': 'Study is collecting data',
      'submitted': 'Study is awaiting approval',
      'draft': 'Study has not been submitted for approval',
      'approved': 'Study is approved but not started',
      'rejected': 'Study has been rejected. Please edit before resubmitting.',
      'retracted': 'Study has been withdrawn',
      'paused': 'Study is not collecting data',
      'deactivated': 'Study is not collecting data',
      'archived': 'Study has been archived and removed from search.'
  }
  
  
  def get_permitted_triggers(view_instance, triggers):
      ''' Get permitted triggers for study state '''
      permitted_triggers = []
      user = view_instance.request.user
      study = view_instance.object
      organization_permissions = get_perms(user, study)
      study_permissions = get_perms(user, view_instance.object )
  
      admin_triggers = ['approve', 'reject']
      for trigger in triggers:
          # remove autogenerated triggers
          if trigger.startswith('to_'):
              continue
  
          # Trigger valid if 1) superuser 2) trigger is admin trigger and user is org admin 3) trigger is found in user's study permissions
          if not user.is_superuser:
              if trigger in admin_triggers:
                   if not (user.organization == study.organization and user.is_org_admin):
                       continue
              elif ('can_' + trigger + '_study') not in study_permissions:
                  continue
  
          permitted_triggers.append(trigger)
  
      return permitted_triggers
  
  
  def update_trigger(view_instance):
      ''' Transition to next state in study workflow '''
      trigger = view_instance.request.POST.get('trigger')
      object = view_instance.get_object()
      if trigger:
          if hasattr(object, trigger):
              # transition through workflow state
              getattr(object, trigger)(user=view_instance.request.user)
      if 'comments-text' in view_instance.request.POST.keys():
          object.comments = view_instance.request.POST['comments-text']
          object.save()
      return object
  
new_contents: from django.utils.text import slugify
  
  from guardian.shortcuts import get_perms
  
  
  def build_org_group_name(org_name, group):
      '''Returns org group name in the form of <ORGNAME>_ORG_<GROUP>'''
      return f'{slugify({org_name})}_ORG_{group}'.upper()
  
  
  def build_study_group_name(org_name, study_name, study_pk, group):
      '''Returns org group name in the form of <ORGNAME>_ORG_<GROUP>'''
      return f'{slugify({org_name})}_{slugify({study_name})}_{study_pk}_STUDY_{group}'.upper()
  
  status_tooltip_text = {
      'created': 'Study has not been submitted for approval',
      'active': 'Study is collecting data',
      'submitted': 'Study is awaiting approval',
      'draft': 'Study has not been submitted for approval',
      'approved': 'Study is approved but not started',
      'rejected': 'Study has been rejected. Please edit before resubmitting.',
      'retracted': 'Study has been withdrawn',
      'paused': 'Study is not collecting data',
      'deactivated': 'Study is not collecting data',
      'archived': 'Study has been archived and removed from search.'
  }
  
  
  def get_permitted_triggers(view_instance, triggers):
      ''' Get permitted triggers for study state '''
      permitted_triggers = []
      user = view_instance.request.user
      study = view_instance.object
      study_permissions = get_perms(user, view_instance.object )
  
      admin_triggers = ['approve', 'reject']
      for trigger in triggers:
          # remove autogenerated triggers
          if trigger.startswith('to_'):
              continue
  
          # Trigger valid if 1) superuser 2) trigger is admin trigger and user is org admin 3) trigger is found in user's study permissions
          if not user.is_superuser:
              if trigger in admin_triggers:
                   if not (user.organization == study.organization and user.is_org_admin):
                       continue
              elif ('can_' + trigger + '_study') not in study_permissions:
                  continue
  
          permitted_triggers.append(trigger)
  
      return permitted_triggers
  
  
  def update_trigger(view_instance):
      ''' Transition to next state in study workflow '''
      trigger = view_instance.request.POST.get('trigger')
      object = view_instance.get_object()
      if trigger:
          if hasattr(object, trigger):
              # transition through workflow state
              getattr(object, trigger)(user=view_instance.request.user)
      if 'comments-text' in view_instance.request.POST.keys():
          object.comments = view_instance.request.POST['comments-text']
          object.save()
      return object
  
subject: Remove unused line.