Vertical Scroll bar django-tables2 - python

Can anyone tell me how to add a vertical scroll bar to django-tables2 instead of having
Page 1 of 2 Next 25 of 49 vehicles
at the bottom of the table.
tables.py
'''
Created on 28 Oct 2016
#author: JXA8341
'''
import django_tables2 as tables
from .models import Vehicle
class CheckBoxColumnWithName(tables.CheckBoxColumn):
#property
def header(self):
return self.verbose_name
class VehicleTable(tables.Table):
update = tables.CheckBoxColumn(accessor="pk",
attrs = { "th__input":{"onclick": "toggle(this)"}},
orderable=False)
class Meta:
model = Vehicle
fields = ('update', 'vehid')
# Add class="paleblue" to <table> tag
attrs = {'class':'paleblue'}
screen.css
table.paleblue + ul.pagination {
font: normal 11px/14px 'Lucida Grande', Verdana, Helvetica, Arial, sans- serif;
overflow: scroll;
margin: 0;
padding: 10px;
border: 1px solid #DDD;
list-style: none;
}
div.table-container {
display: inline-block;
position:relative;
overflow:auto;
}
table.html
<div class='vehlist'>
<script language="JavaScript">
function toggle(source) {
checkboxes = document.getElementsByName('update');
for(var i in checkboxes)
checkboxes[i].checked = source.checked;
}
</script>
<form action="/loadlocndb/" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{% render_table veh_list %}
<h4> Location database .csv file</h4>
{{ form.locndb }}
<input type="submit" value="Submit" />
</form>
</div>
I've looked all over but I can't seem to get a straight answer, or is there a better table module I can use to display the array and checkboxes?

For anyone in the same boat I figured it out.
I turned disabled pagination
RequestConfig(request, pagination=False).configure(veh_list)
then I wrapped the table in a <div> in the html template
<div style="width: 125px; height: 500px; overflow-y: scroll;">
{% render_table veh_list %}
</div>
The <div> then adds a scrollbar to the whole table interface, I personally would have liked to keep the header constantly at the top but this is the best solution I could come up with.

Related

Weasy-print convert to pdf with border image

I’m trying to create pdf file for payment receipt, but I’m not able to figure out how I should set border for it.
As border I want to use this image:
But while converting it to pdf, next page gets like this:
How can I make it constant border for all pages?
Python + Django code:
from weasyprint import HTML
html_string = render_to_string('receipt.html', DATA)
html = HTML(string=html_string)
result = html.write_pdf()
f = open(str(os.path.join(MEDIA_URL + "invoice_receipt/", 'temp.pdf')), 'wb')
f.write(result)
file_obj = File(open(MEDIA_URL + "invoice_receipt/" + "temp.pdf", 'rb'))
transaction.receipt_file = file_obj
transaction.save()
receipt.html template:
<style>
table tbody tr td{
border-top: unset !important;
}
table tbody tr:nth-child(7) td,
table tbody tr:nth-child(8) td,
table tbody tr:nth-child(9) td,
table tbody tr:nth-child(10) td,
table tbody tr:nth-child(11) td,
table tbody tr:nth-child(12) td
{
padding-top: 0;
padding-bottom: 0;
}
.amount-in-words{
border-bottom:3px solid black;
}
.table thead th {
vertical-align: bottom;
border-bottom: 4px solid black;
}
/* .invoice-template{
padding: 20px;
border: 20px solid transparent;
border-image: linear-gradient(to right,#633363 50%,#f3c53d 50%);
border-image-slice: 1;
} */
.logo{
margin-top: 2rem;
}
.logo2{
margin-top: 2rem;
height: 160px;
width:200px;
}
.invoice-template{
padding: 20px;
background-image: url('https://dev-api.test.com/files/files/DumpData/Frame.png');
background-repeat: no-repeat;
background-size: contain;
break-inside: auto;
}
.main-container{
border: 1px solid black;
padding: 20px 10px;
background: white;
}
p {
font-weight: 500;
}
</style>
</head>
<body>
<div class="container invoice-template">
<!-- <div class="main-container"> -->
<div class="row justify-content-center">
<div class="col-md-5 logo"><img src={{ logo }} class="logo2"></div>
<div class="col-md-5 text-right">
<ul style="list-style: none; color: purple; margin-top: 2rem;">
<li>{{ phone }}<span></span></li>
<li><p>{{ email }}<br>{{ website }}</p><span></span></li>
<li>Resource Factory Pvt. Ltd.<br>{{ shop_address|linebreaksbr }}<span></span></li>
</ul>
</div>
</div>
<div class="row text-center">
<div class="col-md-12"><h6>INVOICE</h6></div>
</div>
<div class="row justify-content-center">
<div class="col-md-5">
<p>
To,<br>
{{ user_name }}<br>
{{ user_address|linebreaksbr }}
</p>
<p>Client GST Number.:</p>
</div>
<div class="col-md-5 text-center">
<p>Date: {{ order_date|date:"d-m-Y" }}</p>
<p>Invoice No. {{ invoice }}</p>
</div>
</div>
I’m giving a short version of my html code. If needed full code please mention.
The behavior of box decorations when a box is split (like your main <div> here) is controller by box-decoration-break. Default is slice which breaks the borders after rendering them. clone will compute the borders on each part of the box:
.invoice-template {
box-decoration-break: clone;
}

Creating Relational database with user model in Django. I think i have created relational database but i don't know whats going wrong

I think i have successfully created relation between user model and another table called shop_details but the data is not been inserted. i don't know what is going wrong.
the code is here.
models.py
from django.db import models
from django.contrib.auth.models import User
class Shop_Details(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
shop_name = models.CharField(max_length=50)
shop_street = models.TextField()
shop_area = models.TextField()
city = models.CharField(max_length=50)
state = models.CharField(max_length=50)
pin_code = models.TextField()
my views.py is here
views.py
def shop_detils(request):
if request.method == "POST":
shop_name = request.POST['shop_name']
shop_street = request.POST['shop_street']
shop_area = request.POST['shop_area']
city = request.POST['city']
state = request.POST['state']
pin_code = request.POST['pin_code']
if(len(str(pin_code))!=6):
messages.info(request,"please provide a valid address pin-code")
print("niceee...........................")
return render(request,'shop_details.html')
else:
if(is_number(int(pin_code))):
shop = Shop_Details(shop_name=shop_name,shop_street=shop_street,shop_area=shop_area,city=city,state=state,pin_code=pin_code,user=request.user)
shop.save()
messages.info(request,"Shop Details Updated")
shop_data = Shop_Details.objects.filter(user = request.user)
print(shop_data[1])
print("congrats...........................")
return redirect('home',{'data':shop_data})
else:
messages.info(request,"please provide a valid address")
print("nice2222222222222222222222222")
return render(request,'shop_details.html')
else:
return render(request,'shop_details.html')
my shop_details.html is here
shop_detsils.html
enter code here
{% extends 'layout.html' %}
{% csrf_token %}
{% if user.is_authenticated %}
{% csrf_token %}
{% load static %}
{% csrf_token %}
<meta name="viewport" content="width=device-width, initial-scale=1">
{% csrf_token %}
<body align="center">
{% csrf_token %}
{% csrf_token %}
{% csrf_token %}
{% block content %}
<form action="shop_detils" method="POST">
{% csrf_token %}
<div align="center" class='resp_code frms'>
{% csrf_token %}
<p align='center'<h5><font style='font: 1em/1.3em Tahoma,Geneva,sans-serif;'>
<b>Shop Details</b></font></h5></p>
<div id="selection">
{% csrf_token %}
<table>
{% csrf_token %}
<tr><td>Shop Name: </td><td><input required style="width:200%;" name="shop_name" type="text"></td></tr>
<tr><td>Shop Street: </td><td><input required style="width:200%;" name="shop_street" type="text"></td></tr>
<tr><td>Shop Area: </td><td><input required style="width:200%;" name="shop_area" type="text"></td></tr>
<tr><td>City: </td><td><input required style="width:200%;" name="city" type="text"></td></tr>
<tr><td>State: </td><td><input required style="width:200%" list="state" name="state" type="text"></td></tr>
<datalist id="state">
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Andaman and Nicobar Islands">Andaman and Nicobar Islands</option>
<option value="Arunachal Pradesh">Arunachal Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Dadar and Nagar Haveli">Dadar and Nagar Haveli</option>
<option value="Daman and Diu">Daman and Diu</option>
<option value="Delhi">Delhi</option>
<option value="Lakshadweep">Lakshadweep</option>
<option value="Puducherry">Puducherry</option>
<option value="Goa">Goa</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Manipur">Manipur</option>
<option value="Meghalaya">Meghalaya</option>
<option value="Mizoram">Mizoram</option>
<option value="Nagaland">Nagaland</option>
<option value="Odisha">Odisha</option>
<option value="Punjab">Punjab</option>
<option value="Rajasthan">Rajasthan</option>
<option value="Sikkim">Sikkim</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Telangana">Telangana</option>
<option value="Tripura">Tripura</option>
<option value="Uttar Pradesh">Uttar Pradesh</option>
<option value="Uttarakhand">Uttarakhand</option>
<option value="West Bengal">West Bengal</option>
</datalist>
<tr><td>Pin-code: </td><td><input required name="pin_code" type="text"></td></tr>
</table>
<input style="border-radius: 0.5em; background-color:rgba(2, 2, 253, 0.753);
width:2.5cm;height:0.8cm; font-family: sans-serif;" type="submit" value="Submit">
</div>
</div>
</form>
{% endblock %}
</body>
{% endif %}
my layout.html is here. basically Iam extending layout.html in all html files.
layout.html
<!DOCTYPE html>
{% load static %}
{% csrf_token %}
<html>
<title>GrocSale</title>
<head>
<script language="Javascript" href="{% static 'js/jquery.js' %}"></script>
<script type="text/JavaScript" href="{% static 'js/state.js'%}"></script>
<link rel="stylesheet" type="text/css" href="{% static 'style.css'%}">
</head>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
{% csrf_token %}
<style>
* {box-sizing: border-box}
body{
background:url("{% static 'groc.jpeg' %}") no-repeat;
background-size:cover ;
background-attachment:fixed;
}
body:after {
content: "";
position: fixed;
top: 0; bottom: 0; left: 0; right: 0;
background: hsla(180,0%,50%,0.25);
pointer-events: none;
}
.tab {
float: left;
border: 1px solid #ccc;
background-color: #f1f1f1;
width: 20%;
height: 1000px;
}
/* Style the buttons that are used to open the tab content */
.tab button {
display: block;
background-color: inherit;
color: black;
padding: 22px 16px;
width: 100%;
border: none;
outline: none;
text-align: left;
cursor: pointer;
transition: 0.3s;
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}
/* Create an active/current "tab button" class */
.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
float: left;
padding: 0px 12px;
border: 1px solid #ccc;
width: 70%;
border-left: none;
height: 300px;
}
.divs{
width: 300px;
height: 300px;
border: 1px solid green;
padding: 50px;
float: left;
border-radius: 1em;
box-shadow: 10px 10px;
margin-right: 15px;
margin-left: 15px;
margin-top: 15px;
}
.divs:hover:not(.active) {
background-color: gold;
cursor: grab;
}
</style>
<body>
{% csrf_token %}
<header align="center" style="height: 150px;background-color:orange">
{% csrf_token %}
<strong>
{% csrf_token %}
{% for detail in data%}
<h1>{{detail.shop_name}}</h1>
<h4>Arokya,Hatsun,Arun All Products Available Here</h4>
<h6>{{detail.shop_street}}{{detail.shop_area}}, {{detail.city}}, {{detail.state}} - {{detail.pin_code}}</h6>
{% endfor %}
</strong>
</header>
<div style="background-color:orange;" class="tab" >
{% csrf_token %}
<button class="w3-bar-item w3-button" >Home</button>
<button class="w3-bar-item w3-button" >Add/Update Product</button>
<button class="w3-bar-item w3-button" >Add Stock/Update Stock</button>
<button class="w3-bar-item w3-button" >Add Sale</button>
<button class="w3-bar-item w3-button" >Total Sale</button>
<button class="w3-bar-item w3-button" >Daily Collection Customers</button>
<button class="w3-bar-item w3-button" >Today's Collection Status</button>
<button class="w3-bar-item w3-button" >Show Products</button>
<button class="w3-bar-item w3-button" >All Stock Orders</button>
<button class="w3-bar-item w3-button" >Settings</button>
<a href="{% url 'shop_detils' %}" ><button class="w3-bar-item w3-button" >Shop Details</button></a>
<button class="w3-bar-item w3-button" >Contact Us</button>
<button class="w3-bar-item w3-button" >Logout</button>
</div>
{% block content %}
{% endblock %}
</body>
</html>
Iam still a learner in Django.
Thanks in advance.
my error is shown in image
enter image description here

django.urls.exceptions.NoReverseMatch: Reverse for 'update' with arguments '('',)' not found. 1 pattern(s) tried: ['update/(?P<pk>[0-9]+)$']

im trying to create a django page for update a dta inside database, i made this before in other projects and aways worked, but in my project it returns this error: django.urls.exceptions.NoReverseMatch: Reverse for 'update' with arguments '('',)' not found. 1 pattern(s) tried: ['update/(?P[0-9]+)$']
i reviewed my code a thousand times and i can't see nothing wrong, even if comparing with the other projects.
Obs.: please ignore the css part of my template, i'm not used to write the css inside the html, but as it's just a test i don't create a external file.
urls.py:
from django.urls import path
import tables1.views as vw
urlpatterns = [
path('admin/', admin.site.urls, name = 'admin'),
path('mytables/', vw.mytables, name = 'mytables'),
path('',vw.home),
path('table/<int:pk>',vw.table, name = 'tableurl'),
path('newtable/',vw.newtable,name = 'newtable'),
path('update/<int:pk>',vw.update,name = 'update'),
path('delete/<int:pk>',vw.delete,name = 'delete'),
path('new/',vw.new, name = 'newurl')
]
models.py:
class Table(models.Model):
idd = models.AutoField(primary_key=True, default=None)
name = models.CharField(max_length=100)
date = models.DateField(auto_now_add=True)
time = models.TimeField(auto_now_add=True)
class Meta:
verbose_name_plural = 'Tables'
def __str__(self):
return self.name
class Transacao(models.Model):
# Forein key defined here
date = models.DateTimeField(auto_now_add=True)
desc = models.CharField(max_length=200)
value = models.DecimalField(max_digits=7, decimal_places=2)
obs = models.TextField(null=True, blank=True)
tableid = models.CharField(max_length=3)
class Meta:
verbose_name_plural = 'Transacoes'
def __str__(self):
return self.desc
views.py:
from .models import Table
from .models import Transacao
from .forms import TableForm
from .forms import TransacaoForm
def home(request):
now = {}
return render(request,'tables1/home.html',now)
def mytables(request):
data = {}
data['tables'] = Table.objects.all()
return render(request, 'tables1/mytables.html', data)
def update(request,pk):
transacao = Transacao.objects.get(pk = pk)
form = TransacaoForm(request.POST or None, instance=transacao)
if form.is_valid():
form.save()
return render(request,'tables1/new.html',{'form':form})
def new(request):
form = TransacaoForm(request.POST or None)
if form.is_valid():
form.save()
return render(request,'contas/form.html',{'form':form})
def delete(request,pk):
transacao = Transacao.objects.get(pk = pk)
transacao.delete()
return redirect('lists')
def table(request,pk):
form = TransacaoForm(request.POST or None)
data = Table.objects.get(idd = pk)
lists = Transacao.objects.filter(tableid = pk)
if request.method == 'POST':
if form.is_valid():
formdesc = form.cleaned_data['desc']
formvalue = form.cleaned_data['value']
transaction_instance = Transacao.objects.create(desc = formdesc,value = formvalue,tableid = pk)
return render(request,'tables1/table.html',{'data':data, 'form':form, 'lists':lists})
def newtable(request):
form = TableForm(request.POST or None)
if form.is_valid():
form.save()
return redirect('mytables')
return render(request,'tables1/newtable.html',{'form':form})
table.html:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: Arial, Helvetica, sans-serif;}
* {box-sizing: border-box;}
/* Button used to open the contact form - fixed at the bottom of the page */
.open-button {
background-color: #555;
color: white;
padding: 16px 20px;
border: none;
cursor: pointer;
opacity: 0.8;
}
/* The popup form - hidden by default */
.form-popup {
display: none;
bottom: 0;
right-margin: 10px;
right: 15px;
border: 3px solid #f1f1f1;
z-index: 9;
}
/* Add styles to the form container */
.form-container {
max-width: 300px;
padding: 10px;
background-color: white;
}
/* Full-width input fields */
.form-container input[type=text], .form-container input[type=password] {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
border: none;
background: #f1f1f1;
}
/* When the inputs get focus, do something */
.form-container input[type=text]:focus, .form-container input[type=password]:focus {
background-color: #ddd;
outline: none;
}
/* Set a style for the submit/login button */
.form-container .btn {
background-color: #4CAF50;
color: white;
padding: 16px 20px;
border: none;
cursor: pointer;
width: 100%;
margin-bottom:10px;
opacity: 0.8;
}
/* Add some hover effects to buttons */
.form-container .btn:hover, .open-button:hover {
opacity: 1;
}
</style>
</head>
<body>
<h1>{{data}}</h1>
<table id = tabela>
<tr>
<th>Item</th>
<th>Data e Hora</th>
<th>Valor</th>
</tr>
{% for list in lists %}
<tr>
<td>{{list.desc}}</td><td>{{list.date}}</td>
<td>{{list.value}}</td><td>{{list.categ}}</td>
<td><form action="{% url 'update' transacao.id %}">
<button type="submit"><b>Editar</b></button>
</form></td>
<td><form action="{% url 'delete' transacao.id %}">
<button type="submit"><b>Excluir</b></button>
</form></td>
</tr>
{%endfor%}
</table>
<button class="open-button" onclick="{% url newurl %}">Nova Transação</button>
<form method="post" class="form-container">
{% csrf_token %}
{{form.as_p}}
<button type="submit" class="btn" onclick="location.reload()">Login</button>
<button type="button" class="btn cancel" onclick="closeForm()">Close</button>
</form>
</body>
</html>
transacao is not a variable in your template, you use list as a variable for a Transacao object, therefore you should use {% url 'update' list.id %} and {% url 'delete' list.id %}:
{% for list in lists %}
<tr>
<td>{{ list.desc }}</td><td>{{ list.date }}</td>
<td>{{ list.value }}</td><td>{{ list.categ }}</td>
<td><form action="{% url 'update' list.id %}">
<button type="submit"><b>Editar</b></button>
</form></td>
<td><form action="{% url 'delete' list.id %}">
<button type="submit"><b>Excluir</b></button>
</form></td>
</tr>
{%endfor%}
That being said, since your lists is not a collection of lists - it is a QuerySet of Transacaos - it might be better to rename lists to transacaos and use transacao as "enumerator".

If condition is not working in Inner Loop in django templates

I don't know what is the problem and I've been stuck here for hours. There maybe duplicate questions but none of them could get me out of this.
I am using an if condition in the inner loop to check if the attribute of inner is equal to the outer loop but if condition is never true even the data is same.
I've printed the data individually, both attributes print the data mean data is correct. But when I use if condition it goes to else
Data
Here's the data I'm working with:
activityy.activity_name = [Table Tennis,Swimming Pool, Football ]
slot.activity = [Table Tennis,Table Tennis,Table Tennis,Table Tennis,Swimming Pool, Football]
activities.html
{% for activityy in all_activities%}
<div style="margin-left: 450px; padding: 15px; border-radius: 5px; background-color: #dfdfdf;height: 150px; width: 800px; margin-top: 20px; text-align: center">
{% for slot in all_slots %}
{% if slot.activity == activityy.activity_name %}
<div style="background-color: #3a589a; padding: 15px; width: 120px; height: 120px; float: left; border-radius: 5px;">
<span style="color: #f1f1f1; font-size: 20px;"> {{ activityy.activity_name}}</span><br>
</div>
{% else %}
<div style="background-color: #589a; padding: 15px; width: 120px; height: 120px; float: left; border-radius: 5px;">
<span style="color: #f1f1f1; font-size: 20px;"> {{ slot.activity}}</span><br>
</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
Views.py
def activities(request):
if request.user.is_authenticated:
template = loader.get_template('sklc/activities.html')
slots = []
now = datetime.datetime.now()
datee = now.strftime("%Y-%m-%d")
if request.method == 'POST':
dat = request.POST['date']
if dat:
datee = dat
print("dateesss: " , datee)
activitiess = Activities.objects.all();
for activityy in activitiess:
slot = ActivitySlots.objects.filter(dates=datee).filter(activity__activity_name=activityy.activity_name)
for slott in slot:
slots.append(slott)
context = {
'all_activities': activitiess,
'all_slots': slots
}
return HttpResponse(template.render(context, request))
else:
messages.error(request, "Please Login First")
return redirect("/login")
models.py
class Activities(models.Model):
activity_name = models.CharField(max_length=50)
def __str__(self):
return self.activity_name
class ActivitySlots(models.Model):
dates = models.DateField()
available = models.BooleanField()
activity = models.ForeignKey(Activities)
time = models.CharField(max_length=50)
def __str__(self):
return self.time
I solved it by using
{% if slot.activity == activityy %}
Butt still don't know why it was not working with activityy.activity_name because activityy and activityy_activity_name are printing the same thing.

Moving data from html form to a chart in a MySQL databse using python

I went through a basic web.py tutorial on how to set up a basic server using MySQL and I have a database named 'testdb' with a chart 'todo' inside of it. The values I'm trying to move into the chart are 'email', 'username', and 'password' from the form in index.html. I get the error message 405 method not allowed. And after breaking past 100+ error messages I'm stumped. I already have columns for the three but i have no value assigned to them.
I'm running on a Linux Ubuntu Desktop, in the gedit test editor.
MySQL chart as seen in Terminal
| Field | Type | Null | | Default |
_________________________________________________________
| email | varchar(50) | YES | | NULL |
| username | varchar(50) | YES | | NULL |
| password | varchar(50) | YES | | NULL |
The code for index.html
$def with (todos)
$for todo in todos:
<title>Red.Koala</title>
<body id="background">
<div id="header">
-> Red.Koala <-
</div>
<div id="sign">
<form action="LANForum" method="post">
<table id="tr">
<tr>
Sign In:<br>
</tr>
</table>
Email:<br>
<input id="signbox" type="text" name="email" placeholder="Ex: JoeSmith#example.com" required><br>
Username:<br>
<input id="signbox" type="text" name="username" placeholder="Username..."required><br>
Password:<br>
<input id="signbox" height="30" type="text" name="password" placeholder="Password..." required><br>
<input value="Submit" type="submit" id="signbox" style="margin-top: 20px; right: 5px; width: 50%;">
</div>
</form>
</div>
<div id="copyright">
#HaydnFleming
</div>
<style>
#background {
background: #ff3333;
margin-left: auto;
margin-right: auto;
width: 960px;
}
#header {
border: solid #cc0000;
border-width: 15px;
font-size: 65px;
text-align: center;
}
#sign{
border: solid #cc0000;
border-width: 15px;
font-size: 30px;
text-align: center;
width: 30%;
height: 40%;
margin:auto;
margin-top: 40px ;
margin-bottom: 20%;
}
#signbox {
width: 60%;
height: 10%;
margin-top: 10px;
}
#copyright{
bottom: 2%;
text-align: center;
position: absolute;
width:100%;
}
#tr {
border: solid #cc0000;
position: relative;
width: 100%;
border-bottom: transparent;
border-left: transparent;
border-right: transparent;
}
.dscrptn{
text-align: center;
width: 100%;
position: relative;
z-index: 5;
}
.dscrptn_p{
width: 60%;
text-align: center;
margin: auto;
margin-top: 4%;
position: relative;
border: solid #cc0000;
border-width: 0px;
}
</style>
</body>
The code for Code.py (using Web.py)
import web
render = web.template.render('templates/')
urls = (
'/', 'index', '/add', 'add', '/LANForum', 'LANForum'
)
db = web.database(dbn = 'mysql', user = 'testuser', pw = 'MServer', db = 'testdb')
class index:
def GET(self):
todos = db.select('todo')
return render.index(todos)
class add:
def POST(self):
i = web.input()
n = db.insert('todo', email=i.email, username=i.username, password=i.password)
raise web.seeother('LANForum')
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
The code for LANForum.html
<link type="text/css" rel="stylesheet" href="LANForum.css">
<title>Red.Koala</title>
<body id="background"> <!-- Only used to set up the main background colors/any images.-->
<div id="title">
<!-- I decided to use the title as a nest
for all the other divs to rest in that way
they could all run off of the same measurements,
and they could line up easily using similar
percentages and pixel distances-->
<down>Red.Koala</down>
<!--"down" is just a random word I used as a tag so that I could
separate the text form the divs. also the "+ [Current Forum Title]"
part means that when the website is actually running you will be able
to see the website name and then the forum title. example: Red.Koala/Funny -->
<div id="user">[This is where the current users information will go]</div><!-- User information in the top right-->
<div id="list">[This is where a list of pop. forum topics will go.]</div>
<!-- List of popular forums located on the middle right of the page.-->
<div id="mforum">[This is where your main forum will go.]
<!-- Forum that you are currently on displayed in the big box in the middle of the screen.-->
<div id="post-bar"><!-- Section of the Forum section where any and all posting/commenting will be done -->
<form action="" onsubmit=""><!-- Assigned to whatever server space we select -->
<textarea id="text-box" type="text" placeholder="Post..."></textarea>
<!-- The box which the user will type in to post or comment things -->
<input id="post-button" type="submit" value="Post" required>
</form>
</div>
</div>
</div>
<div id="buttons"><!-- page numbers on display for the user to switch between pages.--> <!--currently not working as buttons-->
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td> <!-- Each cell contains a different page number-->
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>...</td>
</tr>
</table>
</div>
</body>

Categories

Resources