Hall of fame
This commit is contained in:
parent
01cded8763
commit
2feeb35209
3
.gitignore
vendored
3
.gitignore
vendored
@ -103,3 +103,6 @@ ENV/
|
||||
db.sqlite3
|
||||
workspace.xml
|
||||
tasks.xml
|
||||
|
||||
media/icons
|
||||
challenges/migrations
|
||||
|
@ -3,4 +3,5 @@ from challenges.models import *
|
||||
|
||||
admin.site.register(Challenge)
|
||||
admin.site.register(ChallengeTag)
|
||||
admin.site.register(UserChallenge)
|
||||
admin.site.register(UserChallenge)
|
||||
admin.site.register(Profile)
|
||||
|
@ -1,5 +1,31 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
import os
|
||||
|
||||
|
||||
def get_image_path(instance, filename):
|
||||
return os.path.join('icons', str(instance.id), filename)
|
||||
|
||||
|
||||
class Profile(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
icon = models.ImageField(upload_to=get_image_path, default='default_icon.png')
|
||||
|
||||
def __str__(self):
|
||||
return self.user.username
|
||||
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def create_user_profile(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
Profile.objects.create(user=instance)
|
||||
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def save_user_profile(sender, instance, **kwargs):
|
||||
instance.profile.save()
|
||||
|
||||
|
||||
class ChallengeTag(models.Model):
|
||||
@ -13,6 +39,7 @@ class ChallengeTag(models.Model):
|
||||
|
||||
class Challenge(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
creator = models.ForeignKey(User)
|
||||
name = models.CharField(max_length=256)
|
||||
description = models.TextField(blank=True)
|
||||
tags = models.ManyToManyField(ChallengeTag, blank=True)
|
||||
|
@ -124,3 +124,7 @@ STATIC_URL = '/static/'
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'static')
|
||||
]
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
@ -25,4 +25,5 @@ urlpatterns = [
|
||||
url(r'^login/', views.login_view),
|
||||
url(r'^logout/', views.logout_view),
|
||||
url(r'^register/', views.register),
|
||||
] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS)
|
||||
] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS) + \
|
||||
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
@ -14,15 +14,24 @@ def index(request):
|
||||
|
||||
challenges = Challenge.objects.all()
|
||||
challenge_pair = UserChallenge.objects.all()
|
||||
users = User.objects.all()
|
||||
user_data = []
|
||||
|
||||
print(challenge_pair)
|
||||
for u in users:
|
||||
data = {
|
||||
'user': u,
|
||||
'total_challenges': len(UserChallenge.objects.filter(user=u))
|
||||
}
|
||||
user_data.append(data)
|
||||
|
||||
for item in challenge_pair:
|
||||
print(item.user.username)
|
||||
template_dict = {
|
||||
'logged_in': user,
|
||||
'challenges': challenges,
|
||||
'challenge_pair': challenge_pair,
|
||||
'users': user_data
|
||||
}
|
||||
|
||||
return render(request, 'index.html', {'logged_in': user,
|
||||
'challenges': challenges,
|
||||
'challenge_pair': challenge_pair})
|
||||
return render(request, 'landing.html', template_dict)
|
||||
|
||||
|
||||
@csrf_protect
|
||||
@ -72,3 +81,14 @@ def login_view(request):
|
||||
def logout_view(request):
|
||||
logout(request)
|
||||
return HttpResponse('logged out')
|
||||
|
||||
|
||||
def challenge(request):
|
||||
if 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()
|
||||
|
BIN
media/default_icon.png
Normal file
BIN
media/default_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
31
static/css/3-col-portfolio.css
Normal file
31
static/css/3-col-portfolio.css
Normal file
@ -0,0 +1,31 @@
|
||||
/*!
|
||||
* Start Bootstrap - 3 Col Portfolio (http://startbootstrap.com/template-overviews/3-col-portfolio)
|
||||
* Copyright 2013-2017 Start Bootstrap
|
||||
* Licensed under MIT (https://github.com/BlackrockDigital/startbootstrap-3-col-portfolio/blob/master/LICENSE)
|
||||
*/
|
||||
|
||||
body {
|
||||
padding-top: 54px;
|
||||
font-family: "Arial Black", Gadget, sans-serif;
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
body {
|
||||
padding-top: 56px;
|
||||
}
|
||||
}
|
||||
|
||||
.portfolio-item {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.card {
|
||||
width:80%;
|
||||
|
||||
}
|
||||
.achievements{
|
||||
border:5px solid gray;
|
||||
}
|
@ -19,7 +19,21 @@
|
||||
<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>
|
||||
</html>
|
||||
|
99
templates/landing.html
Normal file
99
templates/landing.html
Normal file
@ -0,0 +1,99 @@
|
||||
<!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>
|
Reference in New Issue
Block a user