parent
58e4dbc484
commit
2f2225b01e
|
@ -75,12 +75,12 @@ STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
# Additional locations of static files
|
# Additional locations of static files
|
||||||
STATICFILES_DIRS = (
|
STATICFILES_DIRS = [
|
||||||
os.path.join(BASE_DIR, "static_common"),
|
os.path.join(BASE_DIR, "static_common"),
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
||||||
# Always use forward slashes, even on Windows.
|
# Always use forward slashes, even on Windows.
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
# Don't forget to use absolute paths, not relative paths.
|
||||||
)
|
]
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
# List of finder classes that know how to find static files in
|
||||||
# various locations.
|
# various locations.
|
||||||
|
@ -93,34 +93,56 @@ STATICFILES_FINDERS = (
|
||||||
# Make this unique, and don't share it with anybody.
|
# Make this unique, and don't share it with anybody.
|
||||||
SECRET_KEY = 'InsertSomethingSecretHereBeforeDoingProduktion'
|
SECRET_KEY = 'InsertSomethingSecretHereBeforeDoingProduktion'
|
||||||
|
|
||||||
# List of callables that know how to import templates from various sources.
|
TEMPLATES = [
|
||||||
TEMPLATE_LOADERS = (
|
{
|
||||||
'django.template.loaders.filesystem.Loader',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'django.template.loaders.app_directories.Loader',
|
'DIRS': [os.path.join(BASE_DIR, 'templates'),],
|
||||||
# 'django.template.loaders.eggs.Loader',
|
'APP_DIRS': True,
|
||||||
)
|
'OPTIONS': {
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE = [
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
# Uncomment the next line for simple clickjacking protection:
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
]
|
||||||
)
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'past3d.urls'
|
ROOT_URLCONF = 'past3d.urls'
|
||||||
|
|
||||||
# Python dotted path to the WSGI application used by Django's runserver.
|
# Python dotted path to the WSGI application used by Django's runserver.
|
||||||
WSGI_APPLICATION = 'past3d.wsgi.application'
|
WSGI_APPLICATION = 'past3d.wsgi.application'
|
||||||
|
|
||||||
TEMPLATE_DIRS = (
|
|
||||||
os.path.join(BASE_DIR, 'templates'),
|
# Password validation
|
||||||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
)
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
|
@ -173,3 +195,5 @@ LOGGING = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
@ -17,3 +17,4 @@ urlpatterns = [
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Generated by Django 4.2.3 on 2023-07-12 18:10
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import pastebin.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Geometry',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=128)),
|
||||||
|
('description', models.TextField(blank=True)),
|
||||||
|
('date', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('expiration', models.IntegerField(choices=[(0, 'one hour'), (1, 'one day'), (2, 'one week'), (3, 'one month'), (4, 'forever')], default=0)),
|
||||||
|
('public', models.BooleanField(default=True)),
|
||||||
|
('polycount', models.IntegerField(blank=True, default=0)),
|
||||||
|
('width', models.FloatField(blank=True, default=0)),
|
||||||
|
('depth', models.FloatField(blank=True, default=0)),
|
||||||
|
('height', models.FloatField(blank=True, default=0)),
|
||||||
|
('file', models.FileField(upload_to=pastebin.models.model_path)),
|
||||||
|
('sourcefile', models.FileField(blank=True, upload_to=pastebin.models.source_path)),
|
||||||
|
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -12,19 +12,26 @@ from django.db import models
|
||||||
vertex_pattern = re.compile(r'vertex\s+([0-9.e+-]+)\s+([0-9.e+-]+)\s+([0-9.e+-]+)')
|
vertex_pattern = re.compile(r'vertex\s+([0-9.e+-]+)\s+([0-9.e+-]+)\s+([0-9.e+-]+)')
|
||||||
|
|
||||||
|
|
||||||
def safe_upload_path(base_dir):
|
|
||||||
|
|
||||||
def generate_path(instance, filename):
|
|
||||||
|
|
||||||
ext = os.path.splitext(filename)[1]
|
def model_path(instance, filename):
|
||||||
|
ext = os.path.splitext(filename)[1]
|
||||||
|
md5sum = md5()
|
||||||
|
md5sum.update(instance.name.encode('utf-8') +
|
||||||
|
str(datetime.now()).encode('utf-8') +
|
||||||
|
filename.encode('utf-8'))
|
||||||
|
randomname = md5sum.hexdigest()
|
||||||
|
return os.path.join('models', '%s%s' % (randomname, ext))
|
||||||
|
|
||||||
md5sum = md5()
|
def source_path(instance, filename):
|
||||||
md5sum.update(instance.name + str(datetime.now()) + filename)
|
ext = os.path.splitext(filename)[1]
|
||||||
randomname = md5sum.hexdigest()
|
md5sum = md5()
|
||||||
|
md5sum.update(instance.name.encode('utf-8') +
|
||||||
|
str(datetime.now()).encode('utf-8') +
|
||||||
|
filename.encode('utf-8'))
|
||||||
|
randomname = md5sum.hexdigest()
|
||||||
|
return os.path.join('sources', '%s%s' % (randomname, ext))
|
||||||
|
|
||||||
return os.path.join(base_dir, '%s%s' % (randomname, ext))
|
|
||||||
|
|
||||||
return generate_path
|
|
||||||
|
|
||||||
|
|
||||||
class Geometry(models.Model):
|
class Geometry(models.Model):
|
||||||
|
@ -55,8 +62,8 @@ class Geometry(models.Model):
|
||||||
width = models.FloatField(blank=True, default=0)
|
width = models.FloatField(blank=True, default=0)
|
||||||
depth = models.FloatField(blank=True, default=0)
|
depth = models.FloatField(blank=True, default=0)
|
||||||
height = models.FloatField(blank=True, default=0)
|
height = models.FloatField(blank=True, default=0)
|
||||||
file = models.FileField(upload_to=safe_upload_path('models'))
|
file = models.FileField(upload_to=model_path)
|
||||||
sourcefile = models.FileField(upload_to=safe_upload_path('sources'), blank=True)
|
sourcefile = models.FileField(upload_to=source_path, blank=True)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('geometry_details', kwargs={'id': self.pk})
|
return reverse('geometry_details', kwargs={'id': self.pk})
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block title %} {{ geometry.name }} {% endblock %}
|
{% block title %} {{ geometry.name }} {% endblock %}
|
||||||
|
|
||||||
|
@ -12,9 +13,9 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script src="{{STATIC_URL}}js/jquery-1.10.2.min.js"></script>
|
<script src="{% static 'js/jquery-1.10.2.min.js' %}"></script>
|
||||||
<script src="{{STATIC_URL}}js/thingview.js/three.min.js"></script>
|
<script src="{% static 'js/thingview.js/three.min.js' %}"></script>
|
||||||
<script src="{{STATIC_URL}}js/thingview.js/thingiview.js"></script>
|
<script src="{% static 'js/thingview.js/thingiview.js' %}"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(window).load(function() {
|
$(window).load(function() {
|
||||||
|
@ -28,7 +29,7 @@
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
thingiurlbase = "{{STATIC_URL}}js/thingview.js";
|
thingiurlbase = "{% static 'js/thingview.js' %}";
|
||||||
thingiview = new Thingiview("viewer",100,10);
|
thingiview = new Thingiview("viewer",100,10);
|
||||||
thingiview.initScene();
|
thingiview.initScene();
|
||||||
thingiview.setObjectColor('#C0D8F0');
|
thingiview.setObjectColor('#C0D8F0');
|
||||||
|
@ -173,7 +174,7 @@
|
||||||
{% if geometry.sourcefile %}
|
{% if geometry.sourcefile %}
|
||||||
<a class="pure-button button-lightblue" href="{{geometry.sourcefile.url}}"><i class="icon-edit-sign"></i> Download Source</a>
|
<a class="pure-button button-lightblue" href="{{geometry.sourcefile.url}}"><i class="icon-edit-sign"></i> Download Source</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.is_authenticated and user.id = geometry.user.id %}
|
{% if user.is_authenticated and user.id == geometry.user.id %}
|
||||||
<h2><i class="icon-trash"></i> Delete</h2>
|
<h2><i class="icon-trash"></i> Delete</h2>
|
||||||
<a class="pure-button button-red" href="{% url 'geometry_delete' id=geometry.id %}"><i class="icon-remove-circle"></i> Delete model</a><br/>
|
<a class="pure-button button-red" href="{% url 'geometry_delete' id=geometry.id %}"><i class="icon-remove-circle"></i> Delete model</a><br/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class GeometryCreate(CreateView, LastesGeometriesMixin):
|
||||||
return reverse('geometry_details', kwargs={'id': self.object.id})
|
return reverse('geometry_details', kwargs={'id': self.object.id})
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
if self.request.user.is_authenticated():
|
if self.request.user.is_authenticated:
|
||||||
return GeometryForm
|
return GeometryForm
|
||||||
else:
|
else:
|
||||||
return AnonymousGeometryForm
|
return AnonymousGeometryForm
|
||||||
|
@ -50,7 +50,7 @@ class GeometryCreate(CreateView, LastesGeometriesMixin):
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
res = super(GeometryCreate, self).form_valid(form)
|
res = super(GeometryCreate, self).form_valid(form)
|
||||||
|
|
||||||
if self.request.user.is_authenticated():
|
if self.request.user.is_authenticated:
|
||||||
self.object.user = self.request.user
|
self.object.user = self.request.user
|
||||||
self.object.save()
|
self.object.save()
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
|
{% load static %}
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>past3d :: {% block title %}{% endblock %}</title>
|
<title>past3d :: {% block title %}{% endblock %}</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{STATIC_URL}}css/pure/pure-min.css">
|
<link rel="stylesheet" href="{% static 'css/pure/pure-min.css' %}">
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{STATIC_URL}}css/font-awesome/css/font-awesome.min.css">
|
<link rel="stylesheet" href="{% static 'css/font-awesome/css/font-awesome.min.css' %}">
|
||||||
<!--[if IE 7]>
|
<!--[if IE 7]>
|
||||||
<link rel="stylesheet" href="{{STATIC_URL}}css/font-awesome/css/font-awesome-ie7.min.css">
|
<link rel="stylesheet" href="{{STATIC_URL}}css/font-awesome/css/font-awesome-ie7.min.css">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{STATIC_URL}}css/layout.css">
|
<link rel="stylesheet" href="{% static 'css/layout.css' %}">
|
||||||
|
|
||||||
{% block headeraddons %}
|
{% block headeraddons %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue