Skip to content

Commit c5abd47

Browse files
committedMar 27, 2024·
update settings py
1 parent 3df59dc commit c5abd47

File tree

9 files changed

+135
-22
lines changed

9 files changed

+135
-22
lines changed
 

‎DOSPORTAL/apps.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.apps import AppConfig
2+
3+
4+
class DosportalConfig(AppConfig):
5+
name = 'DOSPORTAL'
6+
7+
def ready(self):
8+
import DOSPORTAL.signals

‎DOSPORTAL/settings.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
'django.contrib.messages',
4040
'django.contrib.staticfiles',
4141
'django.contrib.postgres',
42+
'django.contrib.gis',
4243
'bootstrap5',
4344
#'background_task',
4445
#'django_json_widget',
@@ -105,7 +106,8 @@
105106
# 'NAME': BASE_DIR / 'db.sqlite3',
106107
# }
107108
"default": {
108-
"ENGINE": "django.db.backends.postgresql",
109+
#"ENGINE": "django.db.backends.postgresql",
110+
"ENGINE": "django.contrib.gis.db.backends.postgis",
109111
"NAME": "dosportal",
110112
"USER": "dosportal_user",
111113
"PASSWORD": "dosportal_password",
@@ -147,15 +149,6 @@
147149

148150
USE_TZ = True
149151

150-
151-
# Static files (CSS, JavaScript, Images)
152-
# https://docs.djangoproject.com/en/4.2/howto/static-files/
153-
154-
STATIC_URL = 'static/'
155-
156-
# Default primary key field type
157-
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
158-
159152
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
160153

161154

@@ -168,6 +161,9 @@
168161
STATIC_ROOT = BASE_DIR / 'static'
169162
STATIC_URL = 'static/'
170163

164+
MEDIA_ROOT = BASE_DIR / 'data/media'
165+
MEDIA_URL = 'media/'
166+
171167
REST_FRAMEWORK = {
172168
# Use Django's standard `django.contrib.auth` permissions,
173169
# or allow read-only access for unauthenticated users.
@@ -211,9 +207,10 @@
211207
'save_limit': 250,
212208
'queue_limit': 500,
213209
'cpu_affinity': 1,
214-
'label': 'Django Q',
215-
#'redis': {
216-
# 'host': '127.0.0.1',
210+
'label': 'Worker',
211+
'redis': {
212+
'host': 'redis',
217213
# 'port': 6379,
218214
# 'db': 0, }
215+
}
219216
}

‎DOSPORTAL/signals.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from django.db.models.signals import post_save
2+
from django.contrib.auth.models import User
3+
from django.dispatch import receiver
4+
from .models import Profile, record
5+
6+
7+
@receiver(post_save, sender=User)
8+
def create_profile(sender, instance, created, **kwargs):
9+
if created:
10+
Profile.objects.create(user=instance)
11+
12+
13+
@receiver(post_save, sender=User)
14+
def save_profile(sender, instance, **kwargs):
15+
instance.profile.save()
16+
17+
18+
19+
@receiver(post_save, sender=record)
20+
def save_record(sender, instance, **kwargs):
21+
print("AFTER SAVE.... ")
22+
print(sender)
23+
print(instance)
24+
print(kwargs)
25+
26+
filepath = 'data/media/'+instance.log_file
27+
print(filepath)
28+
29+
metadata = instance.metadata
30+
31+
if 'device_info' not in metadata:
32+
metadata['device_info'] = {}
33+
34+
with open(filepath, 'r') as file:
35+
for line in file:
36+
print(line)
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
3+
{% extends "base.html" %}
4+
{% load crispy_forms_tags %}
5+
6+
{% block content %}
7+
8+
<div class="d-flex justify-content-between"><div class="h1">Edit detector</div>
9+
10+
<div class="container">
11+
<div class="row">
12+
<div class="col-md-12">
13+
<form action="" method="post">
14+
{% csrf_token %}
15+
{{ detectorEditForm | crispy }}
16+
<button class="btn btn-success is-success is-fullwidth is-medium mt-5" type="submit"> Submit </button>
17+
</form>
18+
</div>
19+
</div>
20+
</div>
21+
</div>
22+
23+
24+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
{% extends "base.html" %}
3+
{% load martortags %}
4+
5+
{% block content %}
6+
7+
Organizace <a href="{%url 'organization-detail' slug=organization.slug %}"><b> {{ organization.name }} {% if user.is_authenticated %} <a href="{{organization.get_admin_url}}"><i class="bi bi-pencil"></i></a>{%endif%}</b>
8+
9+
<br>
10+
11+
<div class="d-flex flex-wrap align-items-center text-decoration-none">
12+
{% for a in organization.user_organizations.all %}
13+
<a href="{%url 'user_profile' username=a.user.username %}" class="text-decoration-none">
14+
<div class="d-flex align-items-center m-2">
15+
<img src="{{a.user.profile.image.url}}" class="rounded-circle" alt="{{a.user.full_name }}" style="width: 40px; height: 40px; object-fit: cover;">
16+
<small class="ml-2 py-2 pr-3">{{a.user}}</small>
17+
</div>
18+
</a>
19+
{% endfor %}
20+
</div>
21+
22+
23+
24+
</div>
25+
26+
<hr>
27+
28+
<h2>Detectors</h2>
29+
{% for detector in organization.detectors.all %}
30+
31+
32+
<a href="{% url 'detector-view' pk=detector.pk %}"> {{detector}}</a> <br>
33+
{% endfor %}
34+
<hr>
35+
<h2>Maintainer of detectors:</h2>
36+
37+
TODO:
38+
39+
<h2>Author of measurements</h2>
40+
41+
TODO:
42+
43+
44+
45+
46+
{% endblock %}

‎DOSPORTAL/templates/records/record_detail.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<li><strong>Advanced metadata:</strong></li>
3737
<div class="callout">{{record.metadata }}</div>
3838
<li><strong>Description:</strong> {{record}}
39-
<li><strong>File size:</strong> {{record.log_file.size}}
39+
{# <li><strong>File size:</strong> {{record.log_file.size}} #}
4040

4141
</ul>
4242
</div>

‎DOSPORTAL/templates/records/record_new.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% block content %}
88

99
<div class="column is-one-third">
10-
<form method="post">
10+
<form method="post" enctype="multipart/form-data">
1111
{% csrf_token %}
1212
{{ form | crispy }}
1313
<button class="btn btn-primary is-success is-fullwidth is-medium mt-5" type="submit"> Submit </button>

‎DOSPORTAL/templates/records/records_list.html

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
{% block content %}
55
<div class="d-flex justify-content-between"><div class="h1">Recorded data</div>
66

7+
{{ records_list|length}}
8+
79
{% if user.is_authenticated %}
810
<a href="/record/new" class="btn btn-outline-success" role="button" style="height: max-content;"><i class="bi bi-plus-square me-2"></i> New record </a>
911
{% endif %}
@@ -16,18 +18,17 @@
1618
<th scope="col">#</th>
1719
<th scope="col">Name</th>
1820
<th scope="col">Type</th>
19-
<th scope="col">Autor</th>
20-
<th scope="col">Popis</th>
21+
<th scope="col">Author</th>
2122
</tr>
2223
</thead>
2324
<tbody>
2425
{% for record in record_list.reverse %}
2526
<tr>
26-
<th scope="row">{{ forloop.counter }}</th>
27-
<td><a href="/record/{{record.id}}/" class="link" style="text-decoration: none;">{{ record.name }}</a></td>
27+
<th scope="row"><a href="{%url 'record-view' pk=record.id %}">{{ forloop.counter }}</a></th>
28+
<td><a href="{%url 'record-view' pk=record.id %}" class="link" style="text-decoration: none;">{{ record | truncatechars:50 }}</a></td>
2829
<td>{{ record.record_type }}</td>
2930
<td>{{record.author}}</td>
30-
<td> <div style="max-height: 50pt;overflow-y: auto;">{{record.description | safe_markdown }}</div></td>
31+
<td> <div style="max-height: 50pt;overflow-y: auto;">{{ record }}</div></td>
3132
</tr>
3233

3334
{% endfor %}

‎DOSPORTAL/templates/user/user_profile.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% block content %}
66

7-
<p>Username: {{ user.username }} {% if user.is_authenticated %} <a href="{{user.get_admin_url}}"><i class="bi bi-pencil"></i></a>{%endif%}</p>
7+
<p>Username: {{ user.username }} {% if user.is_authenticated %} <a href="{{ user.get_admin_url }}"><i class="bi bi-pencil"></i></a>{%endif%}</p>
88
<p>Email: {{ user.email }}</p>
99
<p>First Name: {{ user.first_name }}</p>
1010
<p>Last Name: {{ user.last_name }}</p>
@@ -15,7 +15,7 @@ <h3> Organisations: </h3>
1515

1616
{% for a in user.organization_users.all %}
1717

18-
<a href="{{a.get_absolute_url}}">{{a}}</a><br>
18+
<a href="{{a.organization.get_absolute_url}}">{{a}}</a><br>
1919
{% endfor %}
2020

2121

0 commit comments

Comments
 (0)
Please sign in to comment.