Skip to content

Commit

Permalink
sonar complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
rloomans committed Apr 3, 2017
1 parent 685a0e4 commit 59a4c12
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 32 deletions.
5 changes: 2 additions & 3 deletions teamtemp/responses/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ def clean_archive_schedule(self):

def clean_next_archive_date(self):
next_archive_date = self.cleaned_data['next_archive_date']
if next_archive_date is not None:
if next_archive_date < timezone.now().date():
raise forms.ValidationError('Next Archive Date must not be past')
if next_archive_date is not None and next_archive_date < timezone.now().date():
raise forms.ValidationError('Next Archive Date must not be past')
return next_archive_date

def clean_survey_type(self):
Expand Down
17 changes: 17 additions & 0 deletions teamtemp/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,20 @@ ul {
width: 167px;
vertical-align: middle;
}

.centre {
text-align: center;
}

.top {
vertical-align: top;
}

.nowrap {
text-wrap: none;
white-space: nowrap;
}

.filters>tbody>tr>td {
padding: 2px;
}
36 changes: 18 additions & 18 deletions teamtemp/templates/bvc.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

{% block body %}

<div class="container" align="center">
<div class="container">
<div class="row">
<div class="no-print">
<BR>
Expand Down Expand Up @@ -137,25 +137,25 @@
{% csrf_token %}
<div class="no-print">
<BR>
<table cellpadding="2">
<table class="filters">
<tr>
<td valign="top">
<td class="top">
{% if form.filter_dept_names.value %}
{{ form.filter_dept_names.errors }}
<div class="btn btn-default text-left">
{{ form.filter_dept_names }}
</div>
{% endif %}
</td>
<td valign="top">
<td class="top">
{% if form.filter_region_names.value %}
{{ form.filter_region_names.errors }}
<div class="btn btn-default text-left">
{{ form.filter_region_names }}
</div>
{% endif %}
</td>
<td valign="top">
<td class="top">
{% if form.filter_site_names.value %}
{{ form.filter_site_names.errors }}
<div class="btn btn-default text-left">
Expand All @@ -164,11 +164,11 @@
{% endif %}
</td>

<td valign="top">
<td class="top">
{% if form.filter_site_names.value or form.filter_region_names.value or form.filter_dept_names.value %}
{% buttons %}
<button type="submit" class="btn btn-default">
{% bootstrap_icon "glyphicon glyphicon-filter" %} <b>FILTER BVC</b>
{% bootstrap_icon "glyphicon glyphicon-filter" %} <strong>FILTER BVC</strong>
</button>
{% endbuttons %}
{% endif %}
Expand Down Expand Up @@ -235,30 +235,30 @@
{% endif %}
</div>
<div class="row">
<h1 align="center">{{ bvc_data.pretty_team_name }} {{ bvc_data.survey_type_title }}</h1>
<h1 class="center">{{ bvc_data.pretty_team_name }} {{ bvc_data.survey_type_title }}</h1>

<div class="col-md-6">
{% if bvc_data.archived %}
<h2 align="center">{{ bvc_data.archive_date|date:"M. d, Y" }}</h2>
<h2 class="center">{{ bvc_data.archive_date|date:"M. d, Y" }}</h2>
{% else %}
<h2 align="center">{% now () %}</h2>
<h2 class="center">{% now () %}</h2>

<div class="no-print">
{% if num_iterations != '0' %}
{% if bvc_data.team_name == '' %}
<h6 align="center"><a href="{% url 'bvc' survey_id=survey.id %}">Current Results
<h6 class="center"><a href="{% url 'bvc' survey_id=survey.id %}">Current Results
+ {{ num_iterations }} Previous Iterations</a></h6>
{% else %}
<h6 align="center"><a href="{% url 'bvc' survey_id=survey.id team_name=bvc_data.team_name %}">Current
<h6 class="center"><a href="{% url 'bvc' survey_id=survey.id team_name=bvc_data.team_name %}">Current
Results + {{ num_iterations }} Previous Iterations</a></h6>
{% endif %}
{% else %}
{% if bvc_data.team_name == '' %}
<h6 align="center"><a
<h6 class="center"><a
href="{% url 'bvc' survey_id=survey.id num_iterations='2' %}">Current
Results</a></h6>
{% else %}
<h6 align="center"><a
<h6 class="center"><a
href="{% url 'bvc' survey_id=survey.id team_name=bvc_data.team_name num_iterations='2' %}">Current
Results</a></h6>
{% endif %}
Expand All @@ -280,7 +280,7 @@ <h6 align="center"><a
{% endif %}
</div>
<div class="col-md-6">
<h3 align="center">{{ bvc_data.stats.count }} Response{% if bvc_data.stats.count != 1 %}s{% endif %}:</h3>
<h3 class="center">{{ bvc_data.stats.count }} Response{% if bvc_data.stats.count != 1 %}s{% endif %}:</h3>

<div class="wordcloud">
{% if bvc_data.word_cloud_url %}
Expand All @@ -297,10 +297,10 @@ <h3 align="center">{{ bvc_data.stats.count }} Response{% if bvc_data.stats.count
<div class="row">
<br><br>
<!-- History Trend Graphs -->
<h1 align="center">{{ bvc_data.pretty_team_name }}</h1>
<h1 class="center">{{ bvc_data.pretty_team_name }}</h1>
<p>
<h1 align="center">Historical {{ bvc_data.survey_type_title }}</h1>
<h2 align="center">{% now () %}</h2>
<h1 class="center">Historical {{ bvc_data.survey_type_title }}</h1>
<h2 class="center">{% now () %}</h2>
<p>
<div class="centregauge" id="table_div_jscode"></div>
<br><br>
Expand Down
2 changes: 1 addition & 1 deletion teamtemp/templates/password.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% block body %}
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3" align="center">
<div class="col-md-6 col-md-offset-3 center">
<h1>Enter the admin password</h1>
<p></p>
<div class="row">
Expand Down
4 changes: 2 additions & 2 deletions teamtemp/templates/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ <h2>Individual Responses</h2>
<font size="2">This survey is configured to auto archive every {{ archive_schedule }}
days and generate a summary from all collected results for the current iteration for all teams using
this survey.<br><br>
<b>Next scheduled archive will execute on {{ next_archive_date }}.</b></font>
<strong>Next scheduled archive will execute on {{ next_archive_date }}.</strong></font>
{% else %}
<font size="2">Want to reuse your Survey Link? Would you like a BVC trending your
results over time?<br>
<a href="{% url 'reset' id %}">Click here</a> to <b>clear all current results</b> and generate a
<a href="{% url 'reset' id %}">Click here</a> to <strong>clear all current results</strong> and generate a
summary from all collected results for the current iteration for all teams using this survey.</font>
{% endif %}
<br><br>
Expand Down
8 changes: 4 additions & 4 deletions teamtemp/templates/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="container">
{% if user %}
<h1 align="center">User{% if user %} {{ user.id }}{% endif %}</h1>
<h1 class="center">User{% if user %} {{ user.id }}{% endif %}</h1>
<br><br>

<table class="table table-striped">
Expand All @@ -23,18 +23,18 @@ <h1 align="center">User{% if user %} {{ user.id }}{% endif %}</h1>
{% endif %}

{% if admin_surveys %}
<h1 align="center">Survey Admin</h1>
<h1 class="center">Survey Admin</h1>
<br><br>

<table class="table table-striped">
<tr>
<th nowrap colspan="2">Survey</th>
<th class="nowrap" colspan="2">Survey</th>
<th>Teams</th>
</tr>
{% for survey in admin_surveys %}
<tr>
<th>{{ survey.id }}</th>
<td nowrap>
<td class="nowrap">
<div class="btn-group" role="group" aria-label="nav">
<a href="{% url 'admin' survey_id=survey.id %}" class="btn btn-info" role="button">ADMIN</a>
<a href="{% url 'bvc' survey_id=survey.id %}" class="btn btn-primary" role="button">BVC</a>
Expand Down
7 changes: 3 additions & 4 deletions teamtemp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,9 @@ def prune_word_cloud_cache(_):
rows_deleted += rows

for word_cloud_image in WordCloudImage.objects.all():
if word_cloud_image.image_url:
if not os.path.isfile(media_file(word_cloud_image.image_url)):
rows, _ = word_cloud_image.delete()
rows_deleted += rows
if word_cloud_image.image_url and not os.path.isfile(media_file(word_cloud_image.image_url)):
rows, _ = word_cloud_image.delete()
rows_deleted += rows

print("prune_word_cloud_cache: %d rows deleted" % rows_deleted, file=sys.stderr)
print("prune_word_cloud_cache: Stop at %s" % utc_timestamp(), file=sys.stderr)
Expand Down

0 comments on commit 59a4c12

Please sign in to comment.