Initial bar app.

This commit is contained in:
Vidir Valberg Gudmundsson 2017-08-26 03:48:02 +02:00
parent 365827805c
commit a9f1e4553b
11 changed files with 182 additions and 0 deletions

0
src/bar/__init__.py Normal file
View file

16
src/bar/admin.py Normal file
View file

@ -0,0 +1,16 @@
from django.contrib import admin
from .models import ProductCategory, Product
@admin.register(ProductCategory)
class ProductCategoryAdmin(admin.ModelAdmin):
pass
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ['name', 'price', 'category', 'in_stock']
list_editable = ['in_stock']

7
src/bar/apps.py Normal file
View file

@ -0,0 +1,7 @@
from django.apps import AppConfig
class BarConfig(AppConfig):
name = 'bar'

View file

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-08-25 23:28
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('camps', '0022_camp_colour'),
]
operations = [
migrations.CreateModel(
name='Product',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('price', models.IntegerField()),
('in_stock', models.BooleanField(default=True)),
],
),
migrations.CreateModel(
name='ProductCategory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('name', models.CharField(max_length=255)),
('camp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='camps.Camp')),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='product',
name='category',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bar.ProductCategory'),
),
]

View file

21
src/bar/models.py Normal file
View file

@ -0,0 +1,21 @@
from django.db import models
from utils.models import CampRelatedModel
class ProductCategory(CampRelatedModel):
name = models.CharField(max_length=255)
camp = models.ForeignKey('camps.Camp')
def __str__(self):
return self.name
class Product(models.Model):
name = models.CharField(max_length=255)
price = models.IntegerField()
category = models.ForeignKey(ProductCategory, related_name="products")
in_stock = models.BooleanField(default=True)
def __str__(self):
return self.name

View file

@ -0,0 +1,54 @@
{% load static from staticfiles %}
{% load bootstrap3 %}
{% load menubutton %}
{% static "" as baseurl %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{% block title %}BornHack{% endblock %}</title>
<!-- Bootstrap core CSS -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<!-- FontAwesome CSS -->
<link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="{% static 'css/bornhack.css' %}" rel="stylesheet">
{% bootstrap_javascript jquery=1 %}
<!-- favicon.ico stuff -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="theme-color" content="#ffffff">
</head>
<body>
{% block content %}
<div class="bar-row container container-fluid">
{% for category in categories %}
<h1>{{ category.name }}</h1>
{% for product in category.products.all %}
<div class="bar-product">
<h4 class="name">{{ product.name }}</h4>
<h4 class="pull-right price">{{ product.price }} HAX</h4>
</div>
{% endfor %}
{% endfor %}
</div>
{% endblock %}
</body>
</html>

9
src/bar/views.py Normal file
View file

@ -0,0 +1,9 @@
from .models import ProductCategory, Product
from django.views.generic import ListView
class MenuView(ListView):
model = ProductCategory
template_name = "bar_menu.html"
context_object_name = "categories"

View file

@ -43,6 +43,7 @@ INSTALLED_APPS = [
'teams', 'teams',
'people', 'people',
'tickets', 'tickets',
'bar',
'allauth', 'allauth',
'allauth.account', 'allauth.account',

View file

@ -13,6 +13,7 @@ from sponsors.views import *
from teams.views import * from teams.views import *
from people.views import * from people.views import *
from tickets.views import ShopTicketListView from tickets.views import ShopTicketListView
from bar.views import MenuView
urlpatterns = [ urlpatterns = [
url( url(
@ -263,6 +264,12 @@ urlpatterns = [
name='sponsors' name='sponsors'
), ),
url(
r'^bar/menu$',
MenuView.as_view(),
name='menu'
),
url( url(
r'^villages/', include([ r'^villages/', include([
url( url(

View file

@ -274,3 +274,25 @@ footer {
.sponsor .caption { .sponsor .caption {
text-align: center; text-align: center;
} }
.bar-row {
-moz-column-width: 300px;
-webkit-column-width: 300px;
column-width: 300px;
}
.bar-product {
display: flex;
justify-content: flex-start;
border-bottom: 1px solid lightgrey;
}
.bar-product .name {
width: 900px;
}
.bar-product .price {
width: 300px;
}