Explorar o código

edit model indicatorType - add field url for svg icon
add static avatars for indicatorType

MrOzOn %!s(int64=5) %!d(string=hai) anos
pai
achega
c4474c548a

+ 2 - 2
apps/indicatortype/admin.py

@@ -4,8 +4,8 @@ from apps.indicatortype.models import IndicatorType
 
 
 class IndicatorTypeAdmin(admin.ModelAdmin):
-    fields = ('name', 'mark', 'regexp', 'hint')
-    list_display = ('id', 'name', 'mark', 'regexp', 'hint')
+    fields = ('name', 'mark', 'regexp', 'hint', 'url')
+    list_display = ('id', 'name', 'mark', 'regexp', 'hint', 'url')
     # search_fields = ('name',)
     # ordering = ('-created_date',)
 

+ 19 - 0
apps/indicatortype/migrations/0003_indicatortype_url.py

@@ -0,0 +1,19 @@
+# Generated by Django 3.0.8 on 2020-10-31 19:52
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('indicatortype', '0002_auto_20200723_1641'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='indicatortype',
+            name='url',
+            field=models.CharField(default='', max_length=100),
+            preserve_default=False,
+        ),
+    ]

+ 1 - 0
apps/indicatortype/models.py

@@ -8,6 +8,7 @@ class IndicatorType(models.Model):
     mark = models.CharField(max_length=20)
     regexp = models.CharField(max_length=100)
     hint = models.CharField(max_length=50)
+    url = models.CharField(max_length=100)
 
     def __str__(self):
         # return "Тип измерения № %s - %s" % (self.id, self.name,)

+ 4 - 1
apps/indicatortype/views.py

@@ -1,5 +1,5 @@
 from django.shortcuts import render
-from rest_framework import viewsets
+from rest_framework import viewsets, permissions
 
 from apps.indicatortype.models import IndicatorType
 from apps.indicatortype.serializers import IndicatorTypeSerializer
@@ -8,3 +8,6 @@ from apps.indicatortype.serializers import IndicatorTypeSerializer
 class IndicatorTypeViewSet(viewsets.ReadOnlyModelViewSet):
     queryset = IndicatorType.objects.all()
     serializer_class = IndicatorTypeSerializer
+    permission_classes = [
+        permissions.IsAuthenticatedOrReadOnly  # Or anon users can't register
+    ]

+ 4 - 0
healthdiarybackend/settings.py

@@ -133,6 +133,10 @@ USE_TZ = True
 
 STATIC_URL = '/static/'
 
+STATICFILES_DIRS = (
+        os.path.join(BASE_DIR, 'static'),
+)
+
 REST_FRAMEWORK = {
     'DEFAULT_AUTHENTICATION_CLASSES': [
         'rest_framework.authentication.BasicAuthentication',

+ 2 - 2
healthdiarybackend/urls.py

@@ -30,8 +30,8 @@ from apps.user.serializers import CustomAuthToken
 router = routers.DefaultRouter()
 router.register(r'users', user_views.UserViewSet)
 router.register(r'patients', patient_views.PatientViewSet, Patient)
-router.register(r'indicatortype', indicatortype_views.IndicatorTypeViewSet)
-router.register(r'indicator', indicator_views.IndicatorViewSet, Indicator)
+router.register(r'indicatortypes', indicatortype_views.IndicatorTypeViewSet)
+router.register(r'indicators', indicator_views.IndicatorViewSet, Indicator)
 
 urlpatterns = [
     path('', include(router.urls)),

+ 52 - 0
static/pressure.svg

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
+<g>
+	<g>
+		<g>
+			<path d="M277.333,234.667c0-7.792-4.409-14.329-10.667-18.053v-35.28c0-5.896-4.771-10.667-10.667-10.667
+				s-10.667,4.771-10.667,10.667v35.28c-6.258,3.724-10.667,10.262-10.667,18.053c0,11.76,9.573,21.333,21.333,21.333
+				S277.333,246.427,277.333,234.667z"/>
+			<path d="M437.333,0c-41.865,0-74.667,37.479-74.667,85.333c0,34.341,25.902,95.176,64,105.121v204.212c0,52.938-43.063,96-96,96
+				c-50.943,0-92.335-39.995-95.411-90.176c33.447-4.255,63.411-12.215,63.411-27.158v-41.042c37.604-16.507,64-53.997,64-97.625
+				c0-43.628-26.396-81.119-64-97.625V74.667c0-30.458-124.396-32-149.333-32S0,44.208,0,74.667v298.667
+				c0,30.458,124.396,32,149.333,32c10.102,0,36.546-0.289,64.408-2.615C217.91,463.66,268.686,512,330.667,512
+				C395.365,512,448,459.365,448,394.667V190.454c38.098-9.945,64-70.78,64-105.121C512,37.479,479.198,0,437.333,0z M32.781,74.667
+				C54.427,69.375,98.667,64,149.333,64C200,64,244.24,69.375,265.885,74.667C244.24,79.958,200,85.333,149.333,85.333
+				C98.667,85.333,54.427,79.958,32.781,74.667z M170.667,234.667c0-47.052,38.281-85.333,85.333-85.333
+				s85.333,38.281,85.333,85.333C341.333,281.719,303.052,320,256,320S170.667,281.719,170.667,234.667z"/>
+		</g>
+	</g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+</svg>

+ 5 - 0
static/pulse.svg

@@ -0,0 +1,5 @@
+<svg width="125" height="100" viewBox="0 0 125 100" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M26.7707 12.4115L22.3932 5.97949C19.965 7.63394 17.7611 9.59579 15.8367 11.8162L21.7201 16.9135C23.2014 15.2002 24.8991 13.6868 26.7707 12.4115Z" fill="black"/>
+<path d="M39.4168 7.88585L38.732 0.134766C35.81 0.393767 32.9332 1.02534 30.1715 2.01417L32.7941 9.34113C34.9306 8.57506 37.1561 8.086 39.4168 7.88585Z" fill="black"/>
+<path d="M116.204 40.5711C116.539 38.3216 116.716 36.0514 116.733 33.7773C116.872 15.2619 101.975 0.139857 83.4599 0.000993312C83.2434 -0.000709047 83.027 -0.00022346 82.8105 0.00245168C75.3445 0.0155842 68.1019 2.55088 62.2577 7.19711C57.9685 3.78436 52.9003 1.48764 47.5065 0.512187L46.1369 8.17378C51.2062 9.10764 55.8792 11.5391 59.5534 15.1544L62.2772 17.7809L65.0009 15.1544C69.7386 10.4316 76.156 7.78126 82.8456 7.78467C97.1055 7.62756 108.793 19.0599 108.95 33.3198C108.952 33.4723 108.952 33.6248 108.951 33.7773C108.93 36.0555 108.719 38.3279 108.321 40.5711H83.6004L71.2462 57.5869L59.6157 24.6176L46.8801 41.5984L39.5142 30.5554L29.5102 40.5711H16.1948C15.7962 38.3279 15.5853 36.0555 15.5644 33.7773C15.5367 29.8842 16.3837 26.0344 18.0431 22.5125L11.0118 19.17C8.85592 23.736 7.75206 28.7278 7.78221 33.7773C7.79924 36.0516 7.97604 38.3218 8.3114 40.5711H0V48.3533H10.0857C12.9717 57.5208 18.5596 65.6029 26.1171 71.5405L62.2577 100L98.3983 71.5405C105.956 65.6029 111.544 57.5208 114.43 48.3533H124.515V40.5711H116.204ZM93.5889 65.4275L62.2577 90.0932L30.9265 65.4275C25.2676 60.972 20.9137 55.0738 18.3232 48.3533H32.7203L38.2924 42.7852L46.4948 55.0888L57.1176 40.9602L68.8337 74.1592L87.5694 48.3533H106.192C103.602 55.0738 99.2478 60.972 93.5889 65.4275Z" fill="black"/>
+</svg>

+ 63 - 0
static/temperature.svg

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 340 340" style="enable-background:new 0 0 340 340;" xml:space="preserve">
+<g>
+	<g>
+		<g>
+			<path d="M224,68h30.4c5.6,0,10.4-4.4,10.4-10.4c0-5.6-4.4-10.4-10.4-10.4H224c-5.6,0-10.4,4.4-10.4,10.4S218.4,68,224,68z"/>
+			<path d="M270.4,153.6H224c-5.6,0-10.4,4.4-10.4,10.4c0,5.6,4.4,10.4,10.4,10.4h46.4c5.6,0,10.4-4.4,10.4-10.4
+				S276,153.6,270.4,153.6z"/>
+			<path d="M223.6,209.2c-2.4-4.8-5.6-9.2-9.2-13.6c-2.4-2.8-5.2-5.6-7.6-8.4V60c0-8-1.6-16-4.4-22.8C192.8,14.4,171.6,0,146.8,0
+				c-24.8,0-46,14.4-55.6,37.2C88.4,44.4,86.8,52,86.8,60v127.6c-2.8,2.4-5.2,5.2-7.6,8.4c-3.6,4.4-6.4,8.8-9.2,13.6
+				c-3.6,6.4-6.4,13.2-8,20.4c-2,7.2-2.8,14.4-2.8,22c0,12,2.4,23.2,6.8,33.6c4.4,10.8,11.2,20.4,19.2,28.4s17.6,14.4,28.4,19.2
+				c10.4,4.4,21.6,6.8,33.6,6.8c24.4,0,46.4-10,62-25.6c8-8,14.4-17.6,19.2-28.4c4.4-10.4,6.8-21.6,6.8-33.6c0-7.6-0.8-14.8-2.8-22
+				C230,222.4,227.2,215.6,223.6,209.2z M208.8,277.2c-3.2,8-8.4,15.6-14.8,22c-12,12-29.2,19.6-47.6,19.6c-9.2,0-18-2-25.6-5.2
+				c-8-3.2-15.6-8.4-22-14.8c-6.4-6.4-11.2-13.6-14.8-22c-3.2-8-5.2-16.4-5.2-25.6c0-6,0.8-11.6,2-16.8c1.2-5.6,3.6-10.8,6.4-15.6
+				c2-3.6,4.4-7.2,6.8-10.4c2.8-3.2,5.6-6,8.8-8.8l3.6-3.2v-4.8V60c0-5.2,1.2-10.4,2.8-15.2c2-4.4,4.4-8.4,7.6-12l0.8-0.8
+				c3.6-3.6,8-6.8,12.8-8.8s9.6-2.8,15.2-2.8c5.2,0,10.4,1.2,15.2,2.8c4.8,2,9.2,4.8,12.8,8.8l0.8,0.8c3.2,3.6,6,7.6,7.6,12
+				c2,4.8,2.8,9.6,2.8,15.2v132.4v4.8l3.6,3.2c3.2,2.8,6,5.6,8.8,8.8c2.4,3.2,4.8,6.8,6.8,10.4c2.8,4.8,4.8,10.4,6.4,15.6
+				c1.2,5.2,2,10.8,2,16.8C214,260.8,212,269.6,208.8,277.2z"/>
+			<path d="M224,103.6h46.4c5.6,0,10.4-4.4,10.4-10.4c-0.4-6-4.8-10.4-10.4-10.4H224c-5.6,0-10.4,4.4-10.4,10.4
+				C213.6,98.8,218,103.6,224,103.6z"/>
+			<path d="M224,138.8h30.4c5.6,0,10.4-4.4,10.4-10.4c0-5.6-4.4-10.4-10.4-10.4H224c-5.6,0-10.4,4.4-10.4,10.4
+				C213.6,134,218.4,138.8,224,138.8z"/>
+			<path d="M192.4,226.4c-2-4-4.8-7.2-7.6-10.4c-3.2-3.2-6.4-6-10-8.4l-3.6-2.4v-4V152c0-10-5.6-18.8-15.2-22.4c-2.8-1.2-6-2-9.2-2
+				c-3.2,0-6.4,0.8-9.2,2c-9.2,4-15.2,12.4-15.2,22.4v49.2v4l-3.6,2.4c-3.6,2.4-7.2,5.2-10,8.4c-3.2,3.2-5.6,6.8-7.6,10.4
+				c-2,3.6-3.6,8-4.8,12s-1.6,8.4-1.6,12.8c0,6.8,1.6,13.6,4,20c2.8,6.4,6.4,12,11.2,16.8s10.4,8.8,16.8,11.2c6,2.4,12.8,4,20,4
+				c6.8,0,13.6-1.6,20-4c6.4-2.8,12-6.4,16.8-11.2c4.8-4.8,8.8-10.4,11.2-16.8c2.4-6,4-12.8,4-20c0-4.4-0.4-8.8-1.6-12.8
+				C196,234.4,194.4,230.4,192.4,226.4z"/>
+		</g>
+	</g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+</svg>