Skip to content

Commit

Permalink
wip|
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmolony committed Jan 5, 2024
1 parent aaa54e2 commit d8d9317
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 24 deletions.
26 changes: 13 additions & 13 deletions sensor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class FileType(models.Model):
base_field=models.CharField(max_length=10),
default=["NaN"],
help_text=textwrap.dedent(
r"""A list of strings to recognise as empty values. <br>
r"""A list of strings to recognise as empty values.
Default: ["NaN"] <br>
Default: ["NaN"]
Note: "" is also included by default <br>
Note: "" is also included by default
Example: ["NAN", "-9999", "-9999.0"]
"""
Expand All @@ -23,9 +23,9 @@ class FileType(models.Model):
delimiter = models.CharField(
max_length=5,
help_text=textwrap.dedent(
r"""The character used to separate fields in the file. <br>
r"""The character used to separate fields in the file.
Default: "," <br>
Default: ","
Examples: "," or ";" or "\s+" for whitespace or "\t" for tabs
"""
Expand All @@ -36,24 +36,24 @@ class FileType(models.Model):
base_field=models.CharField(max_length=50),
default=["Tmstamp"],
help_text=textwrap.dedent(
r"""A list of datetime field names. <br>
r"""A list of datetime field names.
Examples: <br>
Examples:
1) Data has a single datetime field named "Tmstamp" which has values like
'2021-06-29 00:00:00.000': ["Tmstamp"] <br>
'2021-06-29 00:00:00.000': ["Tmstamp"]
2) Data has two datetime fields named "Date" and "Time" which have values
like '01.01.1999' and '00:00' respectively: ["Date","Time"] <br>
like '01.01.1999' and '00:00' respectively: ["Date","Time"]
"""
),
)
encoding = models.CharField(
max_length=25,
help_text=textwrap.dedent(
r"""The encoding of the file. <br>
r"""The encoding of the file.
Default: "utf-8" <br>
Default: "utf-8"
Examples: utf-8 or latin-1 or cp1252
"""
Expand All @@ -63,12 +63,12 @@ class FileType(models.Model):
datetime_formats = ArrayField(
base_field=models.CharField(max_length=25),
help_text=textwrap.dedent(
r"""The datetime format of `datetime_columns`. <br>
r"""The datetime format of `datetime_columns`.
See https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
for format codes
Default: "%Y-%m-%d %H:%M:%S" <br>
Default: "%Y-%m-%d %H:%M:%S"
Examples: "%Y-%m-%d %H:%M:%S" for "2021-03-01 00:00:00"
"""
Expand Down
35 changes: 30 additions & 5 deletions sensor/templates/create_file_type.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Save"></input>
</form>
<style>
.question-mark {
display: inline-block;
width: 24px;
height: 24px;
text-align: center;
line-height: 24px;
background-color: #f2f2f2;
border-radius: 50%;
font-family: Arial, sans-serif;
cursor: help;
}
</style>

<div style="text-align: center">
<h1>Create File Type</h1>
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
{% for field in form %}
<div style="margin-bottom: 20px">
{{ field.label_tag }}
{{ field }}
{% if field.help_text %}
<span class="question-mark" title="{{ field.help_text }}">&#63;</span>
{% endif %}
</div>
{% endfor %}
<input type="submit" value="Save"></input>
</form>
</div>
21 changes: 16 additions & 5 deletions sensor/templates/upload_file.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Save"></input>
</form>
<div style="text-align: center">
<h1>Upload File</h1>
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
{% for field in form %}
<div style="margin-bottom: 20px">
{{ field.label_tag }}
{{ field }}
{% if field.help_text %}
<span class="question-mark" title="{{ field.help_text }}">&#63;</span>
{% endif %}
</div>
{% endfor %}
<input type="submit" value="Save"></input>
</form>
</div>
2 changes: 1 addition & 1 deletion sensor/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
urlpatterns = [
path('', views.index),

path('create-file-type/', views.upload_file, name="create-file-type"),
path('create-file-type/', views.create_file_type, name="create-file-type"),
path('upload-file/', views.upload_file, name="upload-file"),
]

0 comments on commit d8d9317

Please sign in to comment.