<commit_before>{# Order edit page. #}

{% extends "base.html" %}

{% block head_title %}
Edit {{ terminology('order') }} '{{ order['title'] }}'
{% end %}

{% block body_title %}
Edit  {% module Icon('order') %}
{{ terminology('order') }} '{{ order['title'] }}'
{% end %}

{% block content %}
<h3>{{ form['title'] }}</h3>

<div class="row">
  <div class="col-md-10">
    <span class="help-block">
      You may save incomplete {{ terminology('orders') }}, but only complete
      {{ terminology('orders') }} can be submitted.
      <a href="{{ settings['MARKDOWN_URL'] }}" target="_blank">Markdown</a>
      notation can be used in multi-line text input fields.
    </span>
  </div>
  <div class="col-md-2">
    <form action="{{ reverse_url('order', order['_id']) }}"
	  class="allow_leaving_without_question"
	  role="form"
	  method="GET">
      <div class="form-group">
	<button type="submit" class="btn btn-default btn-block">
	  <span class="glyphicon glyphicon-remove"></span>
	  Cancel
	</button>
      </div>
    </form>
  </div>
</div>

<form action="{{ reverse_url('order_edit', order['_id']) }}"
      class="allow_leaving_without_question"
      role="form"
      enctype="multipart/form-data"
      method="POST">
  {% module xsrf_form_html() %}

  {% include 'order_edit_save.html' %}

  <div class="form-group">
    <div class="row">
      <div class="col-md-9">
	<label class="control-label" for="__title__">Title</label>
	<input type="text" class="form-control"
	       name="__title__" id="__title__"
	       value="{{ order['title'] }}">
      </div>
    </div>
    <span class="help-block">
      Brief, descriptive title for the {{ terminology('order') }}.
      It is not required to be unique, but it is a good idea
      to make it so anyway.
    </span>
  </div>

  {% if is_staff or settings.get('ORDER_USER_TAGS') %}
  <div class="form-group">
    <div class="row">
      <div class="col-md-9">
	<label class="control-label" for="__tags__">Keywords (tags)</label>
	{# A user was confused by terminology. No change in the code. #}
	{% if is_staff %}
	{% set tags = order.get('tags', []) %}
	{% else %}
	{% set tags = [t for t in order.get('tags', []) if not ':' in t] %}
	{% end %}
	<textarea class="form-control"
		  name="__tags__" id="__tags__" rows="2"
		  >{{ ', '.join(tags) }}</textarea>
      </div>
    </div>
    <span class="help-block">
      Optional keywords (tags) characterizing the {{ terminology('order') }},
      which are used in searches.
      <br>
      Format a keyword as an identifier: Start with a letter, continue
      with letters, digits and/or underscore '_'. Use blank or comma
      ',' as delimiter between keywords.
      {% if is_staff %}
      <br>
      Staff may use namespace prefixes, e.g. "project_id:P12345".
      {% end %}
    </span>
  </div>
  {% end %} {#if is_staff or settings.get('ORDER_USER_TAGS') #}

  <div class="form-group">
    <div class="row">
      <div class="col-md-9">
	<label class="control-label" for="__owner__">Owner</label>
	{% if is_admin %}
	<input type="text" class="form-control"
	       name="__owner__" id="__owner__"
	       value="{{ order['owner'] }}">
	{% elif is_staff %}
	<p id="__owner__" class="form-control-static">{{ order['owner'] }}</p>
	{% else %}
	<select class="form-control" name="__owner__" id="__owner__">
	  {% for colleague in colleagues %}
	    <option {{ colleague == current_user['email'] and 'selected' or '' }}>{{ colleague }}</option>
	  {% end %}
	</select>
	{% end %}
      </div>
    </div>
    <span class="help-block">
      {% if is_admin %}
      The {{ terminology('order') }}'s owner specified by email address.
      May be changed to another account.
      {% else %}
      The {{ terminology('order') }}'s owner may be changed to an account
      in your groups.
      <strong>NOTE:</strong>
      You will then no longer be able to edit the {{ terminology('order') }}.
      {% end %}
    </span>
  </div>

  {# Recursion: 'include' cannot be used! #}
  {% module Template('order_edit_fields.html', fields=fields, order=order, is_staff=is_staff, hidden_fields=hidden_fields) %}

  <div>
    {# Fields must be allowed to influence others, even when hidden. #}
    {% for f in hidden_fields %}
    <input type="hidden" class="visible-if-source"
	   name="{{ f }}" id="{{ f }}" 
	   value="{% module NoneStr(order['fields'].get(f)) %}">
    {% end %}
  </div>

  {% include 'order_edit_save.html' %}<commit_msg>Show owner in order edit page when no colleagues.<commit_after>{# Order edit page. #}

{% extends "base.html" %}

{% block head_title %}
Edit {{ terminology('order') }} '{{ order['title'] }}'
{% end %}

{% block body_title %}
Edit  {% module Icon('order') %}
{{ terminology('order') }} '{{ order['title'] }}'
{% end %}

{% block content %}
<h3>{{ form['title'] }}</h3>

<div class="row">
  <div class="col-md-10">
    <span class="help-block">
      You may save incomplete {{ terminology('orders') }}, but only complete
      {{ terminology('orders') }} can be submitted.
      <a href="{{ settings['MARKDOWN_URL'] }}" target="_blank">Markdown</a>
      notation can be used in multi-line text input fields.
    </span>
  </div>
  <div class="col-md-2">
    <form action="{{ reverse_url('order', order['_id']) }}"
	  class="allow_leaving_without_question"
	  role="form"
	  method="GET">
      <div class="form-group">
	<button type="submit" class="btn btn-default btn-block">
	  <span class="glyphicon glyphicon-remove"></span>
	  Cancel
	</button>
      </div>
    </form>
  </div>
</div>

<form action="{{ reverse_url('order_edit', order['_id']) }}"
      class="allow_leaving_without_question"
      role="form"
      enctype="multipart/form-data"
      method="POST">
  {% module xsrf_form_html() %}

  {% include 'order_edit_save.html' %}

  <div class="form-group">
    <div class="row">
      <div class="col-md-9">
	<label class="control-label" for="__title__">Title</label>
	<input type="text" class="form-control"
	       name="__title__" id="__title__"
	       value="{{ order['title'] }}">
      </div>
    </div>
    <span class="help-block">
      Brief, descriptive title for the {{ terminology('order') }}.
      It is not required to be unique, but it is a good idea
      to make it so anyway.
    </span>
  </div>

  {% if is_staff or settings.get('ORDER_USER_TAGS') %}
  <div class="form-group">
    <div class="row">
      <div class="col-md-9">
	<label class="control-label" for="__tags__">Keywords (tags)</label>
	{# A user was confused by terminology. No change in the code. #}
	{% if is_staff %}
	{% set tags = order.get('tags', []) %}
	{% else %}
	{% set tags = [t for t in order.get('tags', []) if not ':' in t] %}
	{% end %}
	<textarea class="form-control"
		  name="__tags__" id="__tags__" rows="2"
		  >{{ ', '.join(tags) }}</textarea>
      </div>
    </div>
    <span class="help-block">
      Optional keywords (tags) characterizing the {{ terminology('order') }},
      which are used in searches.
      <br>
      Format a keyword as an identifier: Start with a letter, continue
      with letters, digits and/or underscore '_'. Use blank or comma
      ',' as delimiter between keywords.
      {% if is_staff %}
      <br>
      Staff may use namespace prefixes, e.g. "project_id:P12345".
      {% end %}
    </span>
  </div>
  {% end %} {#if is_staff or settings.get('ORDER_USER_TAGS') #}

  <div class="form-group">
    <div class="row">
      <div class="col-md-9">
	<label class="control-label" for="__owner__">Owner</label>
	{% if is_admin %}
	<input type="text" class="form-control"
	       name="__owner__" id="__owner__"
	       value="{{ order['owner'] }}">
	{% elif is_staff %}
	<p id="__owner__" class="form-control-static">{{ order['owner'] }}</p>
	{% elif colleagues %}
	<select class="form-control" name="__owner__" id="__owner__">
	  {% for colleague in colleagues %}
	    <option {{ colleague == current_user['email'] and 'selected' or '' }}>{{ colleague }}</option>
	  {% end %}
	</select>
        {% else %}
	<p id="__owner__" class="form-control-static">{{ order['owner'] }}</p>
	{% end %}
      </div>
    </div>
    <span class="help-block">
      {% if is_admin %}
      The {{ terminology('order') }}'s owner specified by email address.
      May be changed to another account.
      {% else %}
      The {{ terminology('order') }}'s owner may be changed to an account
      in your groups.
      <strong>NOTE:</strong>
      You will then no longer be able to edit the {{ terminology('order') }}.
      {% end %}
    </span>
  </div>

  {# Recursion: 'include' cannot be used! #}
  {% module Template('order_edit_fields.html', fields=fields, order=order, is_staff=is_staff, hidden_fields=hidden_fields) %}

  <div>
    {# Fields must be allowed to influence others, even when hidden. #}
    {% for f in hidden_fields %}
    <input type="hidden" class="visible-if-source"
	   name="{{ f }}" id="{{ f }}" 
	   value="{% module NoneStr(order['fields'].get(f)) %}">
    {% end %}
  </div>

  {% include 'order_edit_save.html' %}
{'fraction_non_alphanumeric': 0.19039185299977862, 'fraction_numerical': 0.003099402258135931, 'mean_word_length': 3.263803680981595, 'pattern_counts': {'":': 0, '<': 141, '<?xml version=': 0, '>': 141, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2247815', 'n_tokens_mistral': 3168, 'n_tokens_neox': 2909, 'n_words': 783}