Compare commits
5 Commits
cd3eb0e07c
...
feature/co
| Author | SHA1 | Date | |
|---|---|---|---|
| dd8eea06e6 | |||
| f531f92b48 | |||
| 69c723d20d | |||
| 3d8803a54b | |||
| b19c7ab448 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -131,6 +131,9 @@ env.bak/
|
||||
venv.bak/
|
||||
testappenv/
|
||||
|
||||
#Directories
|
||||
media/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
4
copyStaticScrips.sh
Normal file
4
copyStaticScrips.sh
Normal file
@ -0,0 +1,4 @@
|
||||
rm -d -r /var/www/testapp/
|
||||
mkdir /var/www/testapp
|
||||
cp -a /root/appdirectory/assets/. /var/www/testapp/static
|
||||
chown -R www-data:www-data /var/www
|
||||
@ -1,4 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import Post
|
||||
from .models import Post, ConusFilePDF
|
||||
# Register your models here.
|
||||
admin.site.register(Post)
|
||||
admin.site.register(ConusFilePDF)
|
||||
@ -6,3 +6,8 @@ class CreatePost(forms.ModelForm):
|
||||
model = models.Post
|
||||
fields = ['title' , 'body' , 'slug' , 'banner']
|
||||
|
||||
|
||||
class UploadFileForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model=models.ConusFilePDF
|
||||
fields = [ 'fileName', 'file']
|
||||
21
post/migrations/0009_conusfilepdf.py
Normal file
21
post/migrations/0009_conusfilepdf.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.1 on 2024-08-30 23:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('post', '0008_post_author'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ConusFilePDF',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('fileName', models.CharField(max_length=32)),
|
||||
('file', models.FileField(upload_to='PDFuploads/')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -1,5 +1,6 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from dynamic_filenames import FilePattern
|
||||
|
||||
# Create your models here.
|
||||
class Post(models.Model):
|
||||
@ -13,5 +14,11 @@ class Post(models.Model):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def user_directory_path(instance, filename):
|
||||
return "user_{0}/{1}".format(instance.user.id, filename)
|
||||
|
||||
|
||||
upload_to_pattern = FilePattern(filename_pattern='PDFuploads/{app_label:.25}/{model_name:.30}/{uuid:base32}{ext}')
|
||||
class ConusFilePDF(models.Model):
|
||||
fileName = models.CharField(max_length=32)
|
||||
#file = models.FileField(upload_to="PDFuploads/")
|
||||
file = models.FileField(upload_to=upload_to_pattern)
|
||||
23
post/templates/post/pdf_list.html
Normal file
23
post/templates/post/pdf_list.html
Normal file
@ -0,0 +1,23 @@
|
||||
{% extends 'layout.html' %}
|
||||
|
||||
{% block title %}
|
||||
PDF
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section>
|
||||
<h1>PDFs</h1>
|
||||
|
||||
{% for pdf in pdfs %}
|
||||
<article class="post">
|
||||
<h2>
|
||||
<a href="{{ pdf.file.url }}">
|
||||
{{ pdf.fileName }}
|
||||
|
||||
</a>
|
||||
|
||||
</h2>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
16
post/templates/post/pdf_page.html
Normal file
16
post/templates/post/pdf_page.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends 'layout.html' %}
|
||||
|
||||
{% block title %}
|
||||
New PDF
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section>
|
||||
<h1>New PDFt</h1>
|
||||
<form class="form-with-validation" action="{% url 'post:pdf_page' %}" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<button class="form-submit">Add Post</button>
|
||||
</form>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@ -6,6 +6,9 @@ app_name = 'post'
|
||||
urlpatterns = [
|
||||
path('', views.post_list, name="list"),
|
||||
path('new-post/', views.post_new, name="new-post"),
|
||||
path('<slug:slug>', views.post_page, name="page"),
|
||||
path('pdf/', views.pdf_page, name="pdf_page"),
|
||||
path('pdf-list', views.pdf_list, name="pdf_list"),
|
||||
path('<slug:slug>', views.post_page, name="page")
|
||||
|
||||
|
||||
]
|
||||
@ -1,5 +1,5 @@
|
||||
from django.shortcuts import render,redirect
|
||||
from .models import Post
|
||||
from .models import Post, ConusFilePDF
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from . import forms
|
||||
|
||||
@ -26,3 +26,20 @@ def post_new(request):
|
||||
else:
|
||||
form = forms.CreatePost()
|
||||
return render(request, 'post/post_new.html', {'form': form})
|
||||
|
||||
|
||||
def pdf_page(request):
|
||||
if request.method == "POST":
|
||||
form = forms.UploadFileForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
#Handleuploaded file
|
||||
form.save()
|
||||
return redirect('post:pdf_page')
|
||||
else:
|
||||
form = forms.UploadFileForm()
|
||||
return render(request, 'post/pdf_page.html', {'form' : form})
|
||||
|
||||
|
||||
def pdf_list(request):
|
||||
pdfs = ConusFilePDF.objects.all()
|
||||
return render(request, 'post/pdf_list.html', {'pdfs': pdfs})
|
||||
0
products/__init__.py
Normal file
0
products/__init__.py
Normal file
3
products/admin.py
Normal file
3
products/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
products/apps.py
Normal file
6
products/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProductsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'products'
|
||||
0
products/migrations/__init__.py
Normal file
0
products/migrations/__init__.py
Normal file
68
products/models.py
Normal file
68
products/models.py
Normal file
@ -0,0 +1,68 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Chapter(models.Model): # chapter first hirachical element Osterosynthese
|
||||
id = models.IntegerField(primary_key=True) #SetPrimarykey
|
||||
title = models.CharField(max_length=100) # or name
|
||||
icon = models.ImageField(default='fallback.png', blank=True)
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Section(models.Model):# second hirachical element # Oberarm
|
||||
id = models.IntegerField(primary_key=True) #SetPrimarykey
|
||||
title = models.CharField(max_length=100) # or name
|
||||
icon = models.ImageField(default='fallback.png', blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Subsection(models.Model):#Proximaler Oberarm
|
||||
id = models.IntegerField(primary_key=True) #SetPrimarykey
|
||||
title = models.CharField(max_length=100) # or name
|
||||
icon = models.ImageField(default='fallback.png', blank=True)
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class ProductType(models.Model): #Platte
|
||||
id = models.IntegerField(primary_key=True) #SetPrimarykey
|
||||
title = models.CharField(max_length=100) # or name
|
||||
icon = models.ImageField(default='fallback.png', blank=True)
|
||||
|
||||
class Manufacturer(models.Model):
|
||||
id = models.IntegerField(primary_key=True) #SetPrimarykey
|
||||
name = models.CharField(max_length=100) # or name
|
||||
icon = models.ImageField(default='fallback.png', blank=True)
|
||||
|
||||
class ContactPerson
|
||||
|
||||
class Product(models.Model):
|
||||
id = models.IntegerField(primary_key=True)
|
||||
ProductType = models.ManyToOneRel(ProductType)
|
||||
chaper = models.ManyToManyField(Chapter)
|
||||
section = models.ManyToManyField(Section)
|
||||
subsection = models.ManyToManyField(Subsection)
|
||||
|
||||
title = models.CharField(max_length=75)
|
||||
name = models.CharField(max_length=75)
|
||||
|
||||
description = models.TextField()
|
||||
|
||||
slug = models.SlugField()
|
||||
date = models.DateTimeField(auto_now_add=True)
|
||||
banner = models.ImageField(default='fallback.png', blank=True)
|
||||
manufacturer = models.ForeignKey(Manufacturer, on_delete=models.CASCADE, default=None) #Kritisch wenn conus medical products are linked to User.objects.get(username='root')company and compony is deleted all products are deleted.
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
"""
|
||||
def user_directory_path(instance, filename):
|
||||
return "user_{0}/{1}".format(instance.user.id, filename)
|
||||
|
||||
upload_to_pattern = FilePattern(filename_pattern='PDFuploads/{app_label:.25}/{model_name:.30}/{uuid:base32}{ext}')
|
||||
class ConusFilePDF(models.Model):
|
||||
fileName = models.CharField(max_length=32)
|
||||
#file = models.FileField(upload_to="PDFuploads/")
|
||||
file = models.FileField(upload_to=upload_to_pattern)
|
||||
"""
|
||||
3
products/tests.py
Normal file
3
products/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
products/views.py
Normal file
3
products/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
@ -7,4 +7,6 @@
|
||||
{% block content %}
|
||||
<h1>Home</h1>
|
||||
<p>Check out my <a href="/about">About</a> page.</p>
|
||||
<p>Upload a new PDF <a href="{% url 'post:pdf_page' %}">click here</a></p>
|
||||
<p>show pdfs <a href="{% url 'post:pdf_list' %}">click here</a></p>
|
||||
{% endblock %}
|
||||
@ -71,6 +71,7 @@ TEMPLATES = [
|
||||
|
||||
WSGI_APPLICATION = 'testapp.wsgi.application'
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = ['https://develop.artemisneo.com']
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||
|
||||
Reference in New Issue
Block a user