allow non-cox to (only) use 1x
This commit is contained in:
		| @@ -1,6 +1,12 @@ | |||||||
| {% macro new() %} | {% macro new() %} | ||||||
|   <form action="/log" method="post" id="form"> |   <form action="/log" method="post" id="form"> | ||||||
|  | 	  {% if loggedin_user.is_cox %} | ||||||
| 		{{ macros::select(data=boats, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"]) }} | 		{{ macros::select(data=boats, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"]) }} | ||||||
|  | 	  {% else %} | ||||||
|  | 	  	{% set ones = boats | filter(attribute="amount_seats", value=1) %} | ||||||
|  | 		{{ macros::select(data=ones, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"]) }} | ||||||
|  |  | ||||||
|  | 	  {% endif %} | ||||||
| 	<script> | 	<script> | ||||||
|           function updateElementsBasedOnSelectedOption() { |           function updateElementsBasedOnSelectedOption() { | ||||||
|             var selectElement = document.getElementById('boat_id'); |             var selectElement = document.getElementById('boat_id'); | ||||||
| @@ -13,8 +19,25 @@ | |||||||
|           document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption); |           document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption); | ||||||
|           document.addEventListener('DOMContentLoaded', updateElementsBasedOnSelectedOption); |           document.addEventListener('DOMContentLoaded', updateElementsBasedOnSelectedOption); | ||||||
| 	</script> | 	</script> | ||||||
| 	{{ macros::select(data=coxes, select_name='shipmaster', selected_id=loggedin_user.id) }} | 	  {% if loggedin_user.is_cox %} | ||||||
|  | 	    <select name="shipmaster" id="shipmaster" class="input rounded-md h-10"> | ||||||
|  | 	      <optgroup label="Steuerpersonen"> | ||||||
|  | 	      	{% for cox in coxes %} | ||||||
|  |                      <option value="{{ cox.id }}" {% if cox.id == loggedin_user.id%} selected {% endif %}>{{ cox.name }}</option> | ||||||
|  | 	             {% endfor %} | ||||||
|  | 	      </optgroup> | ||||||
|  | 	      <optgroup label="Alle Mitglieder"> | ||||||
|  | 	      	{% for user in users%} | ||||||
|  |                      <option value="{{ user.id }}" {% if user.id == loggedin_user.id%} selected {% endif %}>{{ user.name }}</option> | ||||||
|  | 	             {% endfor %} | ||||||
|  | 	      </optgroup> | ||||||
|  |             </select> | ||||||
|  | 	 {% else %} | ||||||
|  | 	 	<input type="hidden" name="shipmaster" value="{{loggedin_user.id}}" /> | ||||||
|  | 	 {% endif %} | ||||||
|  | 	{% if loggedin_user.is_cox %} | ||||||
|           {{ macros::checkbox(label='shipmaster_only_steering', name='shipmaster_only_steering') }} |           {{ macros::checkbox(label='shipmaster_only_steering', name='shipmaster_only_steering') }} | ||||||
|  | 	{% endif %} | ||||||
| 	Departure: <input type="datetime-local" id="datetime-dep" name="departure" required/> | 	Departure: <input type="datetime-local" id="datetime-dep" name="departure" required/> | ||||||
| 	Arrival: <input type="datetime-local" id="datetime-arr" name="arrival" /> | 	Arrival: <input type="datetime-local" id="datetime-arr" name="arrival" /> | ||||||
| 	Destination: <input type="search" list="destinations" placeholder="Destination" name="destination" id="destination" oninput="var inputElement = document.getElementById('destination'); | 	Destination: <input type="search" list="destinations" placeholder="Destination" name="destination" id="destination" oninput="var inputElement = document.getElementById('destination'); | ||||||
| @@ -35,7 +58,9 @@ | |||||||
| 	{{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0) }} | 	{{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0) }} | ||||||
| 	{{ macros::input(label="Kommentar", name="comments", type="text") }} | 	{{ macros::input(label="Kommentar", name="comments", type="text") }} | ||||||
| 	{{ macros::select(data=logtypes, select_name='logtype', default="Normal") }} | 	{{ macros::select(data=logtypes, select_name='logtype', default="Normal") }} | ||||||
|  | 	{% if loggedin_user.is_cox %} | ||||||
| 		{{ log::rower_select(id="newrower", selected=[]) }} | 		{{ log::rower_select(id="newrower", selected=[]) }} | ||||||
|  | 	{% endif %} | ||||||
| 	<input type="submit" /> | 	<input type="submit" /> | ||||||
| 	 | 	 | ||||||
| 	<script> | 	<script> | ||||||
| @@ -72,21 +97,30 @@ | |||||||
|     {% if state == "completed" %} |     {% if state == "completed" %} | ||||||
|         Angekommen: {{ log.arrival}}<br /> |         Angekommen: {{ log.arrival}}<br /> | ||||||
|     {% endif %} |     {% endif %} | ||||||
|  |     {% set amount_rowers = log.rowers | length %} | ||||||
|  |     {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} | ||||||
|  |     {% if log.shipmaster == loggedin_user.id  and state == "on_water" %} | ||||||
|  |       {{ log::home(log=log) }} | ||||||
|  |     {% else %} | ||||||
|       Ziel: {{ log.destination }}<br /> |       Ziel: {{ log.destination }}<br /> | ||||||
|       {% if state == "completed" %} |       {% if state == "completed" %} | ||||||
|           Km: {{ log.distance_in_km }}<br /> |           Km: {{ log.distance_in_km }}<br /> | ||||||
|       {% endif %} |       {% endif %} | ||||||
|  |       {% if log.comments %} | ||||||
|         Kommentare: {{ log.comments }}<br /> |         Kommentare: {{ log.comments }}<br /> | ||||||
|  |       {% endif %} | ||||||
|  |       {% if log.logtype %} | ||||||
| 	Logtype: {{ log.logtype }}<br /> | 	Logtype: {{ log.logtype }}<br /> | ||||||
|  |       {% endif %} | ||||||
|  |       {% if amount_guests > 0 or log.rowers | length > 0 %} | ||||||
|       Ruderer:  |       Ruderer:  | ||||||
|     {% set amount_rowers = log.rowers | length %} |       {% endif %} | ||||||
|     {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} |       {% if amount_guests > 0 %} | ||||||
|               {{ amount_guests }} Gäste (ohne Account) |               {{ amount_guests }} Gäste (ohne Account) | ||||||
|  |       {% endif %} | ||||||
|       {% for rower in log.rowers %} |       {% for rower in log.rowers %} | ||||||
|       	{{ rower.name }} |       	{{ rower.name }} | ||||||
|       {% endfor %} |       {% endfor %} | ||||||
|     {% if log.shipmaster == loggedin_user.id  and state == "on_water" %} |  | ||||||
|       {{ log::home(log=log) }} |  | ||||||
|     {% endif %} |     {% endif %} | ||||||
| {% endmacro show %}     | {% endmacro show %}     | ||||||
|  |  | ||||||
| @@ -106,7 +140,9 @@ | |||||||
|         {{ macros::input(label="Kommentar", name="comments", type="text", value=log.comments) }} |         {{ macros::input(label="Kommentar", name="comments", type="text", value=log.comments) }} | ||||||
|         {{ macros::select(data=logtypes, select_name='logtype', default="Normal", selected_id=log.logtype) }} |         {{ macros::select(data=logtypes, select_name='logtype', default="Normal", selected_id=log.logtype) }} | ||||||
|  |  | ||||||
|  | 	{% if loggedin_user.is_cox %} | ||||||
| 	  {{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }} | 	  {{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }} | ||||||
|  | 	{% endif %} | ||||||
|         <input type="submit" value="AUSFAHRT BEENDEN"/> |         <input type="submit" value="AUSFAHRT BEENDEN"/> | ||||||
|       </form> |       </form> | ||||||
| {% endmacro home %}     | {% endmacro home %}     | ||||||
|   | |||||||
| @@ -77,6 +77,8 @@ | |||||||
|   </select> |   </select> | ||||||
| {% endmacro select %} | {% endmacro select %} | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| {% macro alert(message, type, class='') %} | {% macro alert(message, type, class='') %} | ||||||
| <div class="{{ class }} alert-{{ type }} text-white px-3 py-1 rounded-md text-center"> | <div class="{{ class }} alert-{{ type }} text-white px-3 py-1 rounded-md text-center"> | ||||||
|   {{ message }} |   {{ message }} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user