Improved views and tags

This commit is contained in:
teras 2017-10-08 03:11:04 +03:00
parent 2e3b30a462
commit 6f7028d6cf
11 changed files with 246 additions and 383 deletions

View File

@ -26,7 +26,7 @@ urlpatterns = [
url(r'^logout/', views.logout_view),
url(r'^register/', views.register),
url(r'^challenge/(?P<id>[0-9]+)', views.challenge),
url(r'^challenges/', views.dashboard),
url(r'^challenges/', views.challenges),
url(r'^halloffame/', views.hall_of_fame),
url(r'^profile/(?P<username>[\w.-]+)', views.profile)
] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS) + \

View File

@ -10,6 +10,7 @@ def index(request):
if request.method == 'GET':
return render(request, 'index.html')
@csrf_protect
def register(request):
if request.method == 'GET':
@ -61,27 +62,32 @@ def logout_view(request):
def challenge(request, id):
if request.method == 'GET':
return render(request, 'challenge.html')
data = {
'challenge': Challenge.objects.get(id=id)
}
return render(request, 'challenge.html', data)
elif request.method == 'POST':
if not request.user.is_authenticated:
return HttpResponse('not logged in')
challenge_name = request.POST['challenge_name']
challenge_description = request.POST['challenge_discription']
tags = []
challenge = Challenge(creator=request.user, name=challenge_name, description=challenge_description, tags=tags)
challenge.save()
new_challenge = Challenge(creator=request.user, name=challenge_name, description=challenge_description, tags=tags)
new_challenge.save()
def dashboard(request):
def challenges(request):
if request.method == 'GET':
data = {'challenges': Challenge.objects.all()}
return render(request, 'dashboard.html', data)
data = {
'challenges': Challenge.objects.all()
}
return render(request, 'challenges.html', data)
def hall_of_fame(request):
if request.method == 'GET':
data = {
'users': User.objects.all()
'users': sorted(User.objects.all(), key=lambda x: len(UserChallenge.objects.filter(user=x)), reverse=True)
}
return render(request, 'hall_of_fame.html', data)
@ -89,9 +95,9 @@ def hall_of_fame(request):
def profile(request, username=''):
if request.method == 'GET':
user = User.objects.get(username=username)
challenges = UserChallenge.objects.filter(user=user)
user_challenges = UserChallenge.objects.filter(user=user)
data = {
'user': user,
'challenges': challenges
'challenges': user_challenges
}
return render(request, 'profile.html', data)

View File

@ -14,12 +14,12 @@ footer, .map {
background-color: #34495e !important;
}
.card{
.card {
width: 300px;
margin: 0 auto;
}
.progress{
.progress {
height:10px;
}
@ -27,15 +27,15 @@ a:link {
color: black;
}
a:visited{
a:visited {
color: black;
}
a:hover{
a:hover {
color: #34495e;
}
a:active{
a:active {
color: black;
}
@ -44,6 +44,10 @@ ul {
line-height: 38px;
}
.profile{
.profile {
width:300px;
}
.card.small {
height: auto;
}

View File

@ -20,23 +20,19 @@
<br/><br/><br/>
<!-- dashboard custom -->
<h3 class="center-align">Challenges</h3>
<div class="row container challenges">
<div class="col s12">
<div class="card small">
<div class="card-content">
<div class="card-title">Linnar Viigi muruniiduk lahti muukida</div>
<p>Immo peal, muru on pikk</p>
<div class="card-title">{{ challenge.name }}</div>
<p>{{ challenge.description }}</p>
</br>
<div>
<div class="chip">Electronics</div>
<div class="chip">Physics</div>
<div class="chip">Robotics</div>
{% for tag in challenge.tags.all %}
<div class="chip">{{ tag.name }}</div>
{% endfor %}
</div>
</br>
<div class="center-align">
@ -51,40 +47,39 @@
<!-- dashboard custom -->
<footer class="page-footer">
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">Contact</h5>
<p class="grey-text text-lighten-4">
<i class="material-icons">phone</i>&nbsp;Call Lauri 55 55 5555
</p>
<h5 class="white-text">Sponsors</h5>
<p class="grey-text text-lighten-4">
We have more than 10 companies supporting us financially and by equipment
</br>
<a href="#">I want to become a sponsor</a>
</p>
</div>
<div class="col l4 offset-l2 s12">
<h5 class="white-text">Links</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="#!">Location</a></li>
<li><a class="grey-text text-lighten-3" href="#!">Mission</a></li>
<li><a class="grey-text text-lighten-3" href="#!">People</a></li>
</ul>
</div>
</div>
</div>
<div class="footer-copyright">
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">Contact</h5>
<p class="grey-text text-lighten-4">
<i class="material-icons">phone</i>&nbsp;Call Lauri 55 55 5555
</p>
<h5 class="white-text">Sponsors</h5>
<p class="grey-text text-lighten-4">
We have more than 10 companies supporting us financially and by equipment
</br>
<a href="#">I want to become a sponsor</a>
</p>
</div>
<div class="col l4 offset-l2 s12">
<h5 class="white-text">Links</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="#!">Location</a></li>
<li><a class="grey-text text-lighten-3" href="#!">Mission</a></li>
<li><a class="grey-text text-lighten-3" href="#!">People</a></li>
</ul>
</div>
</div>
</div>
<div class="footer-copyright">
<div class="container">
© 2017 k-space
<!-- <a class="grey-text text-lighten-4 right" href="#!">More Links</a> -->
</div>
© 2017 k-space
<!-- <a class="grey-text text-lighten-4 right" href="#!">More Links</a> -->
</div>
</div>
</footer>
</div>
</div>

101
templates/challenges.html Normal file
View File

@ -0,0 +1,101 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" />
<title>K-space</title>
<link href="https://fonts.googleapis.com/css?family=Orbitron" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="/static/css/materialize.min.css">
<link rel="stylesheet" href="/static/css/app.css">
</head>
<body>
<div id="container" class="grey lighten-4">
<div class="header section center-align">
<h1 class="section darken-2 z-depth-1 white-text"><a href="/">k-space.ee</a></h1>
</div>
<br/><br/><br/>
<!-- dashboard custom -->
<div class="row container">
<div class="section slogan">
<h2 class="center-align" style="font-weight:bold">Challenges<br></h2>
</div>
</div>
<div class="row container challenges">
{% for challenge in challenges %}
<div class="col s12 m6">
<div class="card small">
<div class="card-content">
<div class="card-title">{{ challenge.name }}</div>
<p>{{ challenge.description }}</p>
</br>
<div>
{% for tag in challenge.tags.all %}
<div class="chip">{{ tag.name }}</div>
{% endfor %}
</div>
</br>
<div class="center-align">
<a href="/challenge/{{ challenge.id }}" class="btn-large">I can do it</a>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<!-- dashboard custom -->
<footer class="page-footer">
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">Contact</h5>
<p class="grey-text text-lighten-4">
<i class="material-icons">phone</i>&nbsp;Call Lauri 55 55 5555
</p>
<h5 class="white-text">Sponsors</h5>
<p class="grey-text text-lighten-4">
We have more than 10 companies supporting us financially and by equipment
</br>
<a href="#">I want to become a sponsor</a>
</p>
</div>
<div class="col l4 offset-l2 s12">
<h5 class="white-text">Links</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="#!">Location</a></li>
<li><a class="grey-text text-lighten-3" href="#!">Mission</a></li>
<li><a class="grey-text text-lighten-3" href="#!">People</a></li>
</ul>
</div>
</div>
</div>
<div class="footer-copyright">
<div class="container">
© 2017 k-space
<!-- <a class="grey-text text-lighten-4 right" href="#!">More Links</a> -->
</div>
</div>
</footer>
</div>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script>
<script src="/static/js/app.js"></script>
</body>
</html>

View File

@ -1,99 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" />
<title>K-space</title>
<link href="https://fonts.googleapis.com/css?family=Orbitron" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="/static/css/materialize.min.css">
<link rel="stylesheet" href="/static/css/app.css">
</head>
<body>
<div id="container" class="grey lighten-4">
<div class="header section center-align">
<h1 class="section darken-2 z-depth-1 white-text"><a href="/">k-space.ee</a></h1>
</div>
<br/><br/><br/>
<!-- dashboard custom -->
<h3 class="center-align">Challenges</h3>
<div class="row container challenges">
{% for challenge in challenges %}
<div class="col s12 m6">
<div class="card small">
<div class="card-content">
<div class="card-title">{{ challenge.name }}</div>
<p>{{ challenge.description }}</p>
</br>
<div>
<div class="chip">Electronics</div>
<div class="chip">Physics</div>
<div class="chip">Robotics</div>
</div>
</br>
<div class="center-align">
<a href="/challenge/{{ challenge.id }}" class="btn-large">I can do it</a>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<!-- dashboard custom -->
<footer class="page-footer">
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">Contact</h5>
<p class="grey-text text-lighten-4">
<i class="material-icons">phone</i>&nbsp;Call Lauri 55 55 5555
</p>
<h5 class="white-text">Sponsors</h5>
<p class="grey-text text-lighten-4">
We have more than 10 companies supporting us financially and by equipment
</br>
<a href="#">I want to become a sponsor</a>
</p>
</div>
<div class="col l4 offset-l2 s12">
<h5 class="white-text">Links</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="#!">Location</a></li>
<li><a class="grey-text text-lighten-3" href="#!">Mission</a></li>
<li><a class="grey-text text-lighten-3" href="#!">People</a></li>
</ul>
</div>
</div>
</div>
<div class="footer-copyright">
<div class="container">
© 2017 k-space
<!-- <a class="grey-text text-lighten-4 right" href="#!">More Links</a> -->
</div>
</div>
</footer>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script>
<script src="/static/js/app.js"></script>
</body>
</html>

View File

@ -23,88 +23,85 @@
<!-- landing page custom -->
<div class="row container">
<div class="section slogan">
<h2 class="center-align" style="font-weight:bold">HALL OF FAME<br></h2>
</div>
</div>
<!-- ideas solution success -->
<div class="row container section">
{% for user in users %}
<div class="col s12 m4">
<div class="section center-align">
<div class="card">
<div class="card-content white-text">
<div class="card-image">
<a href="/profile/{{ user.username }}"><img src='/media/{{ user.profile.icon }}'></a>
</div>
<h5 class="card-title" style="padding-top: 10px;color:black;"><a href="/profile/{{ user.username }}"><b>{{ user.username }}</b></a></h5>
<div class="col s12 m1">
<a href="#"><img src="https://images.vexels.com/media/users/3/143424/isolated/preview/2aa6cd7edd894a7cefa4eaf0f5916ee9-lightning-bolt-small-by-vexels.png" width="15" height="15" alt=""></a>
</div>
<div class="col s12 m10">
<div class="progress" style="background-color: #f1f1f1">
<div class="determinate" style="width: 70%; background-color:#ffc107;"></div>
{% for user in users %}
<div class="col s12 m4">
<div class="section center-align">
<div class="card">
<div class="card-content white-text">
<div class="card-image">
<a href="/profile/{{ user.username }}"><img src='/media/{{ user.profile.icon }}'></a>
</div>
</div>
<br>
<div class="col s12 m1">
<a href="#"><img src="https://www.chowan.edu/sites/chowan.edu/files/www/info-areas/sidebar-images/it-help-desk-logo.png" width="15" height="15" alt=""></a>
</div>
<div class="col s12 m10">
<div class="progress" style="background-color: #f1f1f1">
<div class="determinate" style="width: 70%; background-color:#3498db;"></div>
<h5 class="card-title" style="padding-top: 10px;color:black;"><a href="/profile/{{ user.username }}"><b>{{ user.username }}</b></a></h5>
<div class="col s12 m1">
<a href="#"><img src="https://images.vexels.com/media/users/3/143424/isolated/preview/2aa6cd7edd894a7cefa4eaf0f5916ee9-lightning-bolt-small-by-vexels.png" width="15" height="15" alt=""></a>
</div>
</div>
<div class="col s12 m10">
<div class="progress" style="background-color: #f1f1f1">
<div class="determinate" style="width: 70%; background-color:#ffc107;"></div>
</div>
</div>
<br>
<div class="progress" style="background-color:#fff">
<div class="determinate" style="width: 70%; background-color:#ffffff;"></div>
<div class="col s12 m1">
<a href="#"><img src="https://www.chowan.edu/sites/chowan.edu/files/www/info-areas/sidebar-images/it-help-desk-logo.png" width="15" height="15" alt=""></a>
</div>
<div class="col s12 m10">
<div class="progress" style="background-color: #f1f1f1">
<div class="determinate" style="width: 70%; background-color:#3498db;"></div>
</div>
</div>
<div class="progress" style="background-color:#fff">
<div class="determinate" style="width: 70%; background-color:#ffffff;"></div>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<footer class="page-footer">
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">Contact</h5>
<p class="grey-text text-lighten-4">
<i class="material-icons">phone</i>&nbsp;Call Lauri 55 55 5555
</p>
<h5 class="white-text">Sponsors</h5>
<p class="grey-text text-lighten-4">
We have more than 10 companies supporting us financially and by equipment
</br>
<a href="#">I want to become a sponsor</a>
</p>
</div>
<div class="col l4 offset-l2 s12">
<h5 class="white-text">Links</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="#!">Location</a></li>
<li><a class="grey-text text-lighten-3" href="#!">Mission</a></li>
<li><a class="grey-text text-lighten-3" href="#!">People</a></li>
</ul>
</div>
</div>
</div>
</div>
{% endfor %}
<footer class="page-footer">
<div class="footer-copyright">
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">Contact</h5>
<p class="grey-text text-lighten-4">
<i class="material-icons">phone</i>&nbsp;Call Lauri 55 55 5555
</p>
<h5 class="white-text">Sponsors</h5>
<p class="grey-text text-lighten-4">
We have more than 10 companies supporting us financially and by equipment
</br>
<a href="#">I want to become a sponsor</a>
</p>
</div>
<div class="col l4 offset-l2 s12">
<h5 class="white-text">Links</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="#!">Location</a></li>
<li><a class="grey-text text-lighten-3" href="#!">Mission</a></li>
<li><a class="grey-text text-lighten-3" href="#!">People</a></li>
</ul>
</div>
</div>
© 2017 k-space
<!-- <a class="grey-text text-lighten-4 right" href="#!">More Links</a> -->
</div>
<div class="footer-copyright">
<div class="container">
© 2017 k-space
<!-- <a class="grey-text text-lighten-4 right" href="#!">More Links</a> -->
</div>
</div>
</footer>
</div>
</footer>
</div>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>

View File

@ -44,18 +44,14 @@
<div class="section center-align">
<i class="material-icons large">search</i><br/>
<h5 class="row">Discover awesome <b class="blue-text">ideas</b></h5>
<h5>Discover awesome <b class="blue-text">ideas</b></h5>
<div class="row">
<div class="col s12">
<p class="">
Find out what we are struggling with
<br/>
Browse our list of challenges
<br/>
Find out what we are struggling with<br>
Browse our list of challenges<br>
Come up with even more awesome ideas
</p>
</div>
</div>
@ -71,7 +67,7 @@
<div class="row">
<div class="col s12">
<p class="">
Check out our community</br>
Check out our community<br>
Explore our wide range of equipment
</p>
</div>
@ -89,7 +85,7 @@
<h5>Add <b class="green-text">success</b> to your portfolio</h5>
<div class="row">
<div class="col s12">
<p class="left-align">
<p class="">
Your k-space achievements will be visible to all future visitors
</p>
</div>
@ -127,7 +123,7 @@
<div class="container white-text">
<div class="row">
<div class="col s1">Office 21m2</div>
<div class="col s1">Office 21m<sup>2</sup></div>
<div class="col s1">&nbsp;</div>
<div class="col s1">Lockers</div>
<div class="col s1">&nbsp;</div>
@ -137,7 +133,7 @@
<div class="col s1">&nbsp;</div>
<div class="col s1">Moar lockers</div>
<div class="col s1">&nbsp;</div>
<div class="col s1">Office 20m2</div>
<div class="col s1">Office 20m<sup>2</sup></div>
<div class="col s1">&nbsp;</div>
</div>

View File

@ -1,39 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
</head>
<body>
<h1>Logged in user{{ logged_int }}</h1>
<ul>
{% for o in challenges %}
<tr class="row">
{{ o }}
</tr>
{% endfor %}
</ul>
<ul>
{% for i in challenge_pair %}
<tr class="row">
{{ i.user.username }} - {{ i.challenge }}
</tr>
<tr class="picture">
<img src= '{{ i.user.profile.icon }}' style="max-width:10%">
</tr>
{% endfor %}
</ul>
<ul>
{% for i in users %}
<tr class="picture">
<img src= '{{ i.user.profile.icon }}' style="max-width:10%">
</tr>
<tr class="row">
{{ i.username }} - {{i.total_challenges}}
</tr>
{% endfor %}
</ul>
</body>
</html>

View File

@ -1,99 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>3 Col Portfolio - Start Bootstrap Template</title>
<!-- Bootstrap core CSS -->
<link href="static/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<!-- Custom styles for this template -->
<link href="static/css/3-col-portfolio.css" rel="stylesheet">
</head>
<body>
<!-- Page Content -->
<div class="row" style="margin:10%">
<div class="col-7" style="flex-wrap: wrap">
<!-- Page Heading -->
<div class="row">
{% for o in users %}
<div class="col-lg-4 col-sm-6" >
<div class="card">
<a href="#"><img class="card-img" src='media/{{ o.user.profile.icon }}' alt=""></a>
<br>
<h3 style="text-align: center;">{{ o.user.username }}</h3>
<div class="w3-round" >
<div class="row">
<div class="col-sm-1">
<a href="#"><img src="https://images.vexels.com/media/users/3/143424/isolated/preview/2aa6cd7edd894a7cefa4eaf0f5916ee9-lightning-bolt-small-by-vexels.png" width="20" height="20" alt=""></a>
</div>
<div class="col-sm-10">
<div class="w3-light-gray w3-round " style="width:100%;">
<div class="w3-container w3-yellow w3-round w3-center" style="width:75%;">75%</div>
</div><br>
</div>
</div>
<div class="row">
<div class="col-sm-1">
<a href="#"><img src="https://www.chowan.edu/sites/chowan.edu/files/www/info-areas/sidebar-images/it-help-desk-logo.png" width="20" height="20" alt=""></a>
</div>
<div class="col-sm-10">
<div class="w3-light-gray w3-round " style="width:100%;">
<div class="w3-container w3-blue w3-round w3-center" style="width:50%;">50%</div>
</div><br>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="col-1">
</div>
<div class="col-4">
<div class="container achievements">
<table class="table">
<thead>
<tr>
<th> Available Challenges</th>
</tr>
</thead>
<tbody>
{% for challenge in challenges %}
<tr>
<td>{{challenge.name}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<!-- /.container -->
<div class = "container">
</div>
<!-- Footer -->
<footer class="py-5 bg-dark">
<!-- /.container -->
</footer>
<!-- Bootstrap core JavaScript -->
<script src="static/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -57,26 +57,27 @@
</div>
</div>
</div>
<div class="col s12 m2">
</div>
<div class="col s12 m3 l3" >
<h2 class="center-align" style="font-weight:bold;font-size: 50px;">{{ user.username }}<br></h2>
<div class="card" style="width:700px;background-color: #34495e;border-radius: 5px;margin: auto 0">
<div class="card-content white-text">
<span class="card-title" style="font-weight: normal">Description</span>
<p style="font-size: 18px;">I am a very simple man. I am good at processing small bits of information.
I am convenient because I require little food to function effectively.</p><br>
<span class="card-title" style="font-weight: normal">Challenges</span>
<ul>
{% for challenge in challenges %}
<li><a class="grey-text text-lighten-3" href="/challenge/{{ challenge.id }}">{{ challenge.name }}</a></li>
{% empty %}
<li>User has not completed any challenges</li>
{% endfor %}
</ul>
</div>
<div class="card-content white-text">
<span class="card-title" style="font-weight: normal">Description</span>
<p style="font-size: 18px;">I am a very simple man. I am good at processing small bits of information.
I am convenient because I require little food to function effectively.</p><br>
<span class="card-title" style="font-weight: normal">Challenges</span>
<ul>
{% for challenge in challenges %}
<li><a class="grey-text text-lighten-3" href="/challenge/{{ challenge.challenge.id }}">{{ challenge.challenge.name }}</a></li>
{% empty %}
<li>User has not completed any challenges</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
@ -92,7 +93,7 @@
<h5 class="white-text">Sponsors</h5>
<p class="grey-text text-lighten-4">
We have more than 10 companies supporting us financially and by equipment
</br>
<br>
<a href="#">I want to become a sponsor</a>
</p>