Skip to content

Commit

Permalink
dosportal updates
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-dvorak committed Mar 27, 2024
1 parent c5abd47 commit 628b7b2
Show file tree
Hide file tree
Showing 55 changed files with 809 additions and 985 deletions.
Empty file.
15 changes: 15 additions & 0 deletions DOSPORTAL/PART_organizations/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.contrib import admin
from django.urls import path, include
from django.views.generic.base import TemplateView
import uuid

from . import views_organizations

urlpatterns = [


path(r'<uuid:pk>', views_organizations.organization_profile, name='organization-detail'),
path(r'<slug:slug>', views_organizations.organization_profile, name='organization-detail'),
path(r'', views_organizations.organization_profile, name='organization'),

]
20 changes: 20 additions & 0 deletions DOSPORTAL/PART_organizations/views_organizations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import django
from django.shortcuts import render, redirect
from django import forms
from django.http import HttpResponse, JsonResponse
from django.views import generic
from ..models import (Organization, OrganizationUser)

from django.shortcuts import get_object_or_404, redirect, render
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User


@login_required
def organization_profile(request, pk = None, slug = None):
if pk:
organization = Organization.objects.get(pk=pk)
elif slug:
organization = Organization.objects.get(slug=slug)

return render(request, 'organizations/organization_profile.html', {'organization':organization})
6 changes: 6 additions & 0 deletions DOSPORTAL/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def user_count(self, obj):



admin.site.register(Profile)
admin.site.register(DetectorManufacturer)
admin.site.register(measurement)
admin.site.register(Organization, OrganizationAdmin)
Expand All @@ -53,6 +54,11 @@ def user_count(self, obj):
admin.site.register(measurement_campaign)


admin.site.register(Trajectory)
admin.site.register(TrajectoryPoint)

admin.site.register(SpectrumData)

from django_q import models as q_models
from django_q import admin as q_admin

Expand Down
76 changes: 59 additions & 17 deletions DOSPORTAL/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
from django import forms
from .models import Detector, record
from .models import Detector, record, Profile, Organization

from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm


class UserRegisterForm(UserCreationForm):
email = forms.EmailField()

class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']

# Create a UserUpdateForm to update a username and email
class UserUpdateForm(forms.ModelForm):
email = forms.EmailField()

class Meta:
model = User
fields = ['username', 'email']

# Create a ProfileUpdateForm to update image.
class ProfileUpdateForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['image']


class DetectorLogblogForm(forms.Form):
Expand All @@ -14,17 +40,24 @@ class DetectorLogblogForm(forms.Form):


class RecordForm(forms.ModelForm):
log_file = forms.FileField(
required=False,
widget=forms.widgets.FileInput(attrs={
'class': 'form-control',
}),
label="Log file",
help_text="Select a log file to upload."
#widget=forms.FileInput(attrs={
# 'class': 'form-control',
#})
)

user = None
def __init__(self,*args, user=None, **kwargs):
super(RecordForm, self).__init__(*args, **kwargs)
self.user = user


# log_file = forms.FileField(
# required=False,
# widget=forms.widgets.FileInput(attrs={
# 'class': 'form-control',
# }),
# label="Log file",
# help_text="Select a log file to upload."
# #widget=forms.FileInput(attrs={
# # 'class': 'form-control',
# #})
# )

detector = forms.ModelChoiceField(
queryset=Detector.objects.all(),
Expand All @@ -37,13 +70,22 @@ class RecordForm(forms.ModelForm):
)

record_type = forms.ChoiceField(
choices=record.RECORD_TYPES,
widget=forms.Select(attrs={
'class': 'form-control',
})
choices=record.RECORD_TYPES
)

belongs = forms.ModelChoiceField(
queryset=Organization.objects.exclude(user_organizations__user=user),
required=True,
label="Belongs to",
help_text="Select organization this record belongs to."
)

class Meta:
model = record
exclude = ("time_end", "measurement", "log_filename", "metadata", "duration", "time_start", "record_duration")
exclude = ("time_end", "measurement", "log_original_filename", "metadata", "duration", "time_start", "record_duration")


class DetectorEditForm(forms.ModelForm):
class Meta:
model = Detector
fields = ["name", "type", 'sn', "calib", "manufactured_date", "data", "owner", "access"]
Loading

0 comments on commit 628b7b2

Please sign in to comment.