Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move doc to database #1

Merged
merged 1 commit into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified myside/rgnbgn/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file modified myside/rgnbgn/__pycache__/admin.cpython-37.pyc
Binary file not shown.
Binary file modified myside/rgnbgn/__pycache__/models.cpython-37.pyc
Binary file not shown.
Binary file modified myside/rgnbgn/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file modified myside/rgnbgn/__pycache__/views.cpython-37.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion myside/rgnbgn/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib import admin
from rgnbgn.models import Doc

# Register your models here.
admin.site.register(Doc)
16 changes: 0 additions & 16 deletions myside/rgnbgn/html/overpass.html

This file was deleted.

55 changes: 0 additions & 55 deletions myside/rgnbgn/html/rgnbgn.html

This file was deleted.

24 changes: 24 additions & 0 deletions myside/rgnbgn/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.1.4 on 2019-01-02 17:30

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Doc',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('map', models.CharField(max_length=16)),
('author', models.CharField(max_length=32)),
('name', models.CharField(max_length=32)),
('file', models.FileField(upload_to='')),
],
),
]
Binary file not shown.
Binary file modified myside/rgnbgn/migrations/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
7 changes: 6 additions & 1 deletion myside/rgnbgn/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from django.db import models

# Create your models here.

class Doc(models.Model):
map = models.CharField(max_length=16)
author = models.CharField(max_length=32)
name = models.CharField(max_length=32)
file = models.FileField()
23 changes: 23 additions & 0 deletions myside/rgnbgn/templates/rgnbgn/rgnbgn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<title>RegenBogen</title>
</head>

<body>
<h1>RegenBogen
<small class="text-muted">RgnBgn</small>
</h1>
<table class="table">
<tr>
<th>Map</th>
<th>Vorbereiter</th>
<th>Download</th>
</tr>
{% for entry in entries %}
<td>{{entry.map}}</td>
<td>{{entry.author}}</td>
<td> <a class="btn btn-primary" href="/{{entry.file.url}}" role="button">{{entry.name}}</a></td>
{% endfor %}
</table>
</body>
15 changes: 6 additions & 9 deletions myside/rgnbgn/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from django.shortcuts import render
from django.http import HttpResponse, FileResponse, Http404
from rgnbgn.models import Doc


def index(request):
try:
response = HttpResponse(open("rgnbgn/html/rgnbgn.html"))
return response
except FileNotFoundError:
raise Http404()
return render(request, "rgnbgn/rgnbgn.html", {"entries": Doc.objects.all()})


def overpass(request):
Expand Down Expand Up @@ -41,8 +38,8 @@ def overpass_HD(request):
def inferno(request):
try:
response = FileResponse(
open("rgnbgn/inferno.pdf","rb"), content_type="application/pdf")
response["Content-Disposition"]= "attachment; filename=inferno.pdf"
open("rgnbgn/inferno.pdf", "rb"), content_type="application/pdf")
response["Content-Disposition"] = "attachment; filename=inferno.pdf"
return response
except FileNotFoundError:
raise Http404()
Expand All @@ -51,8 +48,8 @@ def inferno(request):
def train(request):
try:
response = FileResponse(
open("rgnbgn/train.pdf","rb"), content_type="application/pdf")
response["Content-Disposition"]= "attachment; filename=train.pdf"
open("rgnbgn/train.pdf", "rb"), content_type="application/pdf")
response["Content-Disposition"] = "attachment; filename=train.pdf"
return response
except FileNotFoundError:
raise Http404()