소스 검색

show categories and projects

https
jakobsn 6 년 전
부모
커밋
4859f1bf74
12개의 변경된 파일86개의 추가작업 그리고 14개의 파일을 삭제
  1. +22
    -2
      README.md
  2. +2
    -1
      src/app/models/database.py
  3. +1
    -0
      src/app/models/guestbook.py
  4. +12
    -7
      src/app/models/project.py
  5. +1
    -0
      src/app/models/register.py
  6. +22
    -0
      src/app/static/stylesheet.css
  7. +1
    -0
      src/app/templates/guestbook.html
  8. +14
    -2
      src/app/templates/index.html
  9. +2
    -1
      src/app/templates/login.html
  10. +1
    -0
      src/app/templates/project.html
  11. +1
    -0
      src/app/templates/register.html
  12. +7
    -1
      src/app/views/index.py

+ 22
- 2
README.md 파일 보기

@@ -9,5 +9,25 @@ webpy framework: http://webpy.org/
### prerequisites: ### prerequisites:
docker https://www.docker.com/ docker https://www.docker.com/


### Run
docker-compose up
### Build & Run
$ docker-compose up --build

### Prune/Recreate
If you need a fresh rebuild in case of startup issues use this command (WARNING this will remove all your docker images)
$ docker system prune -a
$ docker-compose up --build

### Deploy locally

Install:
mysql
src/app/requirements.txt

Run:
Launch mysql at port 3306
Execute mysql queries
"CREATE database db;"
"USE db;"
Populate mysql by posting mysql/sql/init.sql into mysql
Edit src/app/models/database.py to point at local server
python3 src/app/main.py

+ 2
- 1
src/app/models/database.py 파일 보기

@@ -3,6 +3,7 @@ import mysql.connector
db = mysql.connector.connect( db = mysql.connector.connect(
user='root', user='root',
password='root', password='root',
host='10.5.0.5',
#host='10.5.0.5', # Docker address
host='0.0.0.0', # Local address
database='db' database='db'
) )

+ 1
- 0
src/app/models/guestbook.py 파일 보기

@@ -12,6 +12,7 @@ def set_guestbook_entry(entry):
cursor = db.cursor() cursor = db.cursor()
query = ("INSERT INTO guestbook VALUES (NULL, \"" + entry + "\")") query = ("INSERT INTO guestbook VALUES (NULL, \"" + entry + "\")")
cursor.execute(query) cursor.execute(query)
db.commit()
cursor.close() cursor.close()



+ 12
- 7
src/app/models/project.py 파일 보기

@@ -10,14 +10,19 @@ def get_categories():


def set_project(categoryid, userid, title, project_description, project_status): def set_project(categoryid, userid, title, project_description, project_status):
cursor = db.cursor() cursor = db.cursor()
query = ("INSERT INTO projects values (NULL, \"1\", \"1\", \"sad\", \"desdf\", \"open\")")
#("INSERT INTO projects values (NULL, \"" +
#categoryid + "\", \"" + userid + "\", \"" + title + "\", \"" +
#project_description + "\", \"" + project_status + "\")")
print(query)
query = ("INSERT INTO projects VALUES (NULL, \"" +
categoryid + "\", \"" + userid + "\", \"" + title + "\", \"" +
project_description + "\", \"" + project_status + "\")")
cursor.execute(query) cursor.execute(query)
db.commit()
cursor.close() cursor.close()
categories = get_categories() categories = get_categories()
print(categories)
return categories return categories

def get_projects_by_status_and_category(categoryid, project_status):
cursor = db.cursor()
query = ("SELECT * FROM projects WHERE project_status = \"" +
project_status + "\" AND categoryid = \"" + categoryid + "\"")
cursor.execute(query)
projects = cursor.fetchall()
return projects

+ 1
- 0
src/app/models/register.py 파일 보기

@@ -8,4 +8,5 @@ def set_user(username, password, full_name, company, phone_number,
phone_number + "\", \"" + street_address + "\", \"" + city + "\", \"" + phone_number + "\", \"" + street_address + "\", \"" + city + "\", \"" +
state + "\", \"" + postal_code + "\", \"" + country + "\")") state + "\", \"" + postal_code + "\", \"" + country + "\")")
cursor.execute(query) cursor.execute(query)
db.commit()
cursor.close() cursor.close()

+ 22
- 0
src/app/static/stylesheet.css 파일 보기

@@ -5,6 +5,28 @@ body {
margin: 0; margin: 0;
} }


.title {
margin: auto;
}

.categories {
display: flex; /* or inline-flex */
flex-direction: row;
}

.category {
margin: auto;
}

.projects {
display: flex; /* or inline-flex */
flex-direction: row;
}

.projects * {
margin: auto;
}

h1 { h1 {
margin: auto; margin: auto;
} }


+ 1
- 0
src/app/templates/guestbook.html 파일 보기

@@ -4,6 +4,7 @@ $def with (nav, entries, guestbook_form)
<title>Friends</title> <title>Friends</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/stylesheet.css"> <link rel="stylesheet" type="text/css" href="static/stylesheet.css">
<link rel="shortcut icon" type="image/png" href="static/honeybee.png"/>


</head> </head>




+ 14
- 2
src/app/templates/index.html 파일 보기

@@ -1,15 +1,27 @@
$def with (nav)
$def with (nav, categories, projects)

<head> <head>
<title>Beelance2</title> <title>Beelance2</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/stylesheet.css"> <link rel="stylesheet" type="text/css" href="static/stylesheet.css">
<link rel="shortcut icon" type="image/png" href="static/honeybee.png"/>
</head> </head>


<body> <body>


$:nav $:nav
<h1 class="title">Open Projects:</h1>
<div id="categories">
$for category in categories:
<div class="category" onclick="location.href='/?categoryid=$category[0]'">$category[1]</div>
</div>

<div class="projects">
$for project in projects:
<div class="project"><h4>$project[3]</h4><p>$project[4]</p></div>
</div>


<img src="static/honeybee.png" alt="Honeybee"> <img src="static/honeybee.png" alt="Honeybee">




+ 2
- 1
src/app/templates/login.html 파일 보기

@@ -4,6 +4,7 @@ $def with (nav, login_form, friends)
<title>Beelance2</title> <title>Beelance2</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/stylesheet.css"> <link rel="stylesheet" type="text/css" href="static/stylesheet.css">
<link rel="shortcut icon" type="image/png" href="static/honeybee.png"/>


</head> </head>


@@ -22,7 +23,7 @@ $def with (nav, login_form, friends)
<h3>Registered friends:</h3> <h3>Registered friends:</h3>
<ul> <ul>
$for user in friends: $for user in friends:
<li id="user[0]">$user[1]</li>
<li id="$user[0]">$user[1]</li>
</ul> </ul>


</body> </body>

+ 1
- 0
src/app/templates/project.html 파일 보기

@@ -4,6 +4,7 @@ $def with (nav, project_form)
<title>Beelance2</title> <title>Beelance2</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/stylesheet.css"> <link rel="stylesheet" type="text/css" href="static/stylesheet.css">
<link rel="shortcut icon" type="image/png" href="static/honeybee.png"/>


</head> </head>




+ 1
- 0
src/app/templates/register.html 파일 보기

@@ -4,6 +4,7 @@ $def with (nav, register_form)
<title>Beelance2</title> <title>Beelance2</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/stylesheet.css"> <link rel="stylesheet" type="text/css" href="static/stylesheet.css">
<link rel="shortcut icon" type="image/png" href="static/honeybee.png"/>


</head> </head>




+ 7
- 1
src/app/views/index.py 파일 보기

@@ -6,6 +6,7 @@ from views.logout import Logout
from views.register import Register from views.register import Register
from views.admin import Admin from views.admin import Admin
from views.project import Project from views.project import Project
from models.project import get_categories, get_projects_by_status_and_category


# Define application routes # Define application routes
urls = ( urls = (
@@ -45,5 +46,10 @@ class Index:
# Get main page # Get main page
def GET(self): def GET(self):
data = web.input(categoryid=0)
projects=[]
if data.categoryid != 0:
projects = get_projects_by_status_and_category(data.categoryid, "open")
nav = get_nav_bar(session) nav = get_nav_bar(session)
return render.index(nav)
categories = get_categories()
return render.index(nav, categories, projects)

불러오는 중...
취소
저장