Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(project-edit): add a new button for exiting without saving #231

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rse/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ class ServiceProjectForm(forms.ModelForm):
attrs={'class': 'form-control'}),
input_formats=('%d/%m/%Y',))
end = forms.DateField(widget=forms.DateInput(format=('%d/%m/%Y'),
attrs={'class': 'form-control'}),
input_formats=('%d/%m/%Y',))
attrs={'class': 'form-control'}),
input_formats=('%d/%m/%Y',))
invoice_received = forms.DateField(widget=forms.DateInput(format=('%d/%m/%Y'),
attrs={'class': 'form-control'}),
input_formats=('%d/%m/%Y',),
required=False)
attrs={'class': 'form-control'}),
input_formats=('%d/%m/%Y',),
required=False)

class Meta:
model = ServiceProject
Expand Down
233 changes: 117 additions & 116 deletions rse/templates/project_directly_incurred_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,128 +11,132 @@
{% block page_name %}RSE Group Administration Tool: {% if edit %}Edit{% else %}New{% endif %} Directly Incurred Project{% endblock %}
{% block content %}

<div class ="row">

<div class="col-md-8">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title"> {% if edit %}Edit{% else %}New{% endif %} Directly Incurred Project {% if edit %}(Project Internal ID: {{form.instance.id}}){% endif %}</h3>
</div>

<form method="POST" action="{% if edit %}{% url 'project_edit' form.instance.id %}{% else %}{% url 'project_new_directly_incurred' %}{% endif %}">
{% csrf_token %}

<div class="box-body no-padding">

<table id="id_project_table" class="table table-striped">
<tbody>

<tr><td>
<strong>Client:</strong>
<div class="input-group">
{{ form.client}}
<div class="input-group-addon">
<a id="id_add_client" href="{% url 'client_new' %}?next={% url 'project_new_directly_incurred' %}" class="fa fa-plus" data-toggle="tooltip" title="" data-original-title="Create a new client"></a>
</div>
<div class ="row">
<div class="col-md-8">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title"> {% if edit %}Edit{% else %}New{% endif %} Directly Incurred Project {% if edit %}(Project Internal ID: {{form.instance.id}}){% endif %}</h3>
</div>

<form method="POST" action="{% if edit %}{% url 'project_edit' form.instance.id %}{% else %}{% url 'project_new_directly_incurred' %}{% endif %}">
{% csrf_token %}

<div class="box-body no-padding">

<table id="id_project_table" class="table table-striped">
<tbody>

<tr><td>
<strong>Client:</strong>
<div class="input-group">
{{ form.client}}
<div class="input-group-addon">
<a id="id_add_client" href="{% url 'client_new' %}?next={% url 'project_new_directly_incurred' %}" class="fa fa-plus" data-toggle="tooltip" title="" data-original-title="Create a new client"></a>
</div>
</td></tr>
</div>
</td></tr>

<tr><td>
<strong>Project Name:</strong>
{{ form.name}}
</td></tr>

<tr><td>
<strong>Project Internal ID (URMS or equivalent):</strong>
{{ form.proj_costing_id}}
</td></tr>

<tr><td>
<strong>Description / Notes:</strong>
{{ form.description}}
</td></tr>

<tr><td>
<strong>Project Name:</strong>
{{ form.name}}
</td></tr>

<tr><td>
<strong>Project Internal ID (URMS or equivalent):</strong>
{{ form.proj_costing_id}}
</td></tr>

<tr><td>
<strong>Description / Notes:</strong>
{{ form.description}}
</td></tr>

<tr><td>
<strong>Start Date:</strong>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
{{ form.start}}
<tr><td>
<strong>Start Date:</strong>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
</td></tr>

<tr><td>
<strong>End Date:</strong>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
{{ form.end}}
{{ form.start}}
</div>
</td></tr>

<tr><td>
<strong>End Date:</strong>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
</td></tr>

<tr><td>
<strong>Internal:</strong>
{{ form.internal}}
</td></tr>

<tr><td>
<strong>Status:</strong>
{{ form.status}}
</td></tr>

<tr><td>
<strong>Percentage FTE:</strong>
{{ form.percentage}}
</td></tr>

<tr><td>
<strong>Overheads Rate (Pro-Rata):</strong>
{{ form.overheads}}
</td></tr>

<tr><td>
<strong>Salary Band Used for Costing:</strong>
{{ form.salary_band}}
</td></tr>

</tbody>
{{ form.created}}
{{ form.creator}}
</table>
</div>
{{ form.end}}
</div>
</td></tr>

<tr><td>
<strong>Internal:</strong>
{{ form.internal}}
</td></tr>

<tr><td>
<strong>Status:</strong>
{{ form.status}}
</td></tr>

<tr><td>
<strong>Percentage FTE:</strong>
{{ form.percentage}}
</td></tr>

<tr><td>
<strong>Overheads Rate (Pro-Rata):</strong>
{{ form.overheads}}
</td></tr>

<tr><td>
<strong>Salary Band Used for Costing:</strong>
{{ form.salary_band}}
</td></tr>

</tbody>
{{ form.created}}
{{ form.creator}}
</table>
</div>

<div class="box-footer">
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="box-footer">
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
<strong>{{field.label}}: {{ error|escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong>{{field.label}}: {{ error|escape }}</strong>
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endif %}
<input type="submit" name="project_submit" value="Save" class="btn btn-primary btn-xm"></input>
{% if edit and user.is_superuser%}
<button type="button" class="btn btn-danger btn-xm pull-right" data-toggle="modal" data-target="#delete_modal">Delete</button>
{% endif %}
</div>

</form>
</div>
</div>


</div>
{% endif %}

<input type="submit" name="project_submit" value="Save" class="btn btn-primary btn-xm"></input>

{% if edit %}
<a href="{% url 'project' project_id %}">
<button type="button" class="btn btn-warning">Exit without saving</button>
</a>
{% endif %}

{% if edit and user.is_superuser%}
<button type="button" class="btn btn-danger btn-xm pull-right" data-toggle="modal" data-target="#delete_modal">Delete</button>
{% endif %}
</div>
</form>
</div>
</div>
</div>


{% if edit and user.is_superuser %}
{% if edit and user.is_superuser %}
<div class="modal modal-danger fade" id="delete_modal" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
Expand All @@ -156,10 +160,7 @@ <h4 class="modal-title" id="myModalLabel">Are you sure?</h4>
</div>
{% endif %}






{% endblock %}

{% block javascript %}
Expand Down
10 changes: 9 additions & 1 deletion rse/templates/project_service_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,17 @@ <h3 class="box-title"> {% if edit %}Edit{% else %}New{% endif %} Service Project
</div>
{% endfor %}
{% endif %}

<input type="submit" name="project_submit" value="Save" class="btn btn-primary btn-xm"></input>

{% if edit %}
<a href="{% url 'project' project_id %}">
<button type="button" class="btn btn-warning">Exit without saving</button>
</a>
{% endif %}

{% if edit and user.is_superuser %}
<button type="button" class="btn btn-danger btn-xm pull-right" data-toggle="modal" data-target="#delete_modal">Delete</button>
<button type="button" class="btn btn-danger btn-xm pull-right" data-toggle="modal" data-target="#delete_modal">Delete</button>
{% endif %}
</div>

Expand Down
3 changes: 2 additions & 1 deletion rse/views/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from django.http import JsonResponse
from django.conf import settings


from rse.models import *
from rse.forms import *
from rse.views.helper import *
Expand Down Expand Up @@ -199,6 +198,8 @@ def project_edit(request: HttpRequest, project_id) -> HttpResponse:
else:
form = formclass(instance=proj)
view_dict['form'] = form

view_dict['project_id'] = project_id

# Add edit field to indicate delete should be available
view_dict['edit'] = True
Expand Down