Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dlareau committed Jan 4, 2016
2 parents 7ec33cd + b8d42c5 commit f361edf
Show file tree
Hide file tree
Showing 22 changed files with 325 additions and 315 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
*.*~
*.pyc
/static/
/media/
/huntserver/static/huntserver/*.pdf
/huntserver/static/huntserver/*.png
/huntserver/static/huntserver/puzzles/*
/puzzlehunt_server/secret_settings.py
/docs/_build/
/docs/_build/
db.sqlite3
18 changes: 18 additions & 0 deletions huntserver/migrations/0031_auto_20151221_1105.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('huntserver', '0030_auto_20151016_1021'),
]

operations = [
migrations.AlterModelOptions(
name='hunt',
options={'permissions': (('view_task', 'Can see available tasks'),)},
),
]
18 changes: 18 additions & 0 deletions huntserver/migrations/0032_auto_20151221_1242.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('huntserver', '0031_auto_20151221_1105'),
]

operations = [
migrations.AlterModelOptions(
name='hunt',
options={},
),
]
14 changes: 5 additions & 9 deletions huntserver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ class Hunt(models.Model):

@property
def is_locked(self):
if timezone.now() < self.start_date:
return True
return False
return timezone.now() < self.start_date

@property
def is_open(self):
if timezone.now() > self.start_date and timezone.now() < self.end_date:
return True
return False
return timezone.now() > self.start_date and timezone.now() < self.end_date

@property
def is_public(self):
if timezone.now() > self.end_date:
return True
return False
return timezone.now() > self.end_date

def __unicode__(self):
return self.hunt_name
Expand Down
4 changes: 2 additions & 2 deletions huntserver/puzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def unlock_puzzles(team):
# and convert it to PNGs. It first clears the old PNGs and PDFs.
# Has to also get number of pages so that the whole pdf doesn't become one image
def download_puzzles(hunt):
directory = "/home/hunt/puzzlehunt_server/huntserver/static/huntserver/puzzles"
directory = settings.MEDIA_ROOT + "puzzles"
# TODO: maybe move folder, see if success, then delete.
# maybe overwrite files with wget?

Expand All @@ -86,7 +86,7 @@ def download_puzzles(hunt):
for i in range(pages):
call(["convert", "-density", "200", "-scale", "x1000", file_str + "[" + str(i) + "]", directory + "/" + puzzle.puzzle_id + "-" + str(i) + ".png"])

call(["python", "/home/hunt/puzzlehunt_server/manage.py", "collectstatic"])
call(["python", "kmanage.py", "collectstatic"])
#get document: wget {{URL}} -O {{FILENAME}}
#get pages: pdfinfo {{FILENAME}} | grep Pages | awk '{print $2}'
#convert: convert -density 200 -scale x1000 {{FILENAME}}[i] {{OUTFILE}}
Expand Down
6 changes: 6 additions & 0 deletions huntserver/static/bootstrap.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions huntserver/static/bootstrap.min.js

Large diffs are not rendered by default.

Binary file added huntserver/static/huntserver/background.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 20 additions & 65 deletions huntserver/static/huntserver/base.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,24 @@
\html {
background-image: url(http://www.millionaireinvestor.asia/images/Background.jpg);
body {
background: url(/static/huntserver/background.jpg);
}

body {
.content {
font-family: verdana;
font-size: 14px;
margin: 20px;
padding: 20px;
padding: 10px;
padding-top: 0px;
margin-right: 10px;
margin-bottom: 10px;
background: white;
border: 4px solid black;
}

header {
margin: 0 -20px;
margin-top: -20px;
background-color: lightgray;
padding: 15px;
border-bottom: 4px solid black;
overflow: hidden;
}

#container {
overflow: hidden;
}

#content-left {
float: left;
border-right: 4px solid black;
border: 3px solid black;
}

#content-right {
padding: 20px;
border-left: 4px solid black;
margin-left: -4px;
padding-right: 0px;
float: left;
th {
text-align: left;
}

#plot {
width: 450px;
background-color: white; /* maybe gray? */
border: 1px solid black;
padding: 5px;
}

#left-header{
float: left;
}

#right-header{
float: right;
}

.puzzle {
overflow: hidden;
}

th {
text-align: left;
margin-top: 10px;
}

.puzzle td img{
Expand All @@ -66,24 +27,10 @@ th {
height: 30px;
}

/* For the puzzle page */
/*for puzzle page*/
.puzzle, .info {
overflow: auto;
}

.puzzle fieldset {
float: left;
padding: 20px;
margin: 20px;
}

.puzzle fieldset#submit {
width: 30%;
}

.puzzle fieldset#answers {
width: 40%;
}

.puzzle .info h1 {
float: left;
Expand All @@ -93,6 +40,14 @@ th {
float: right;
}

.puzzle fieldset {
margin: 20px;
}

.puzzle fieldset td,th {
padding-right: 10px;
}

.puzzle #puzzleimg {
width: 100%;
max-width: 900px;
Expand Down
8 changes: 4 additions & 4 deletions huntserver/static/huntserver/chat.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#chatcontainer {
border: 1px solid black;
max-width: 900px;
min-height: 100px;
max-height: 400px;
padding: 15px;
background-color: lightgrey;
border-radius:3px;
overflow: auto;
}

.chatselect {
Expand All @@ -21,12 +23,10 @@
#messagebox {
border-radius:3px;
height: 25px;
width: 400px;
float: left;
width: 50%;
margin-right: 10px;
}

#sendbutton {
height: 25px;
float: left;
}
16 changes: 0 additions & 16 deletions huntserver/static/huntserver/low-width.css

This file was deleted.

67 changes: 47 additions & 20 deletions huntserver/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,57 @@
{% load bootstrap_tags %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %} Puzzlehunt! {% endblock title %}</title>
<link rel="stylesheet" href="{{ STATIC_URL }}bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}huntserver/base.css">
<script src="{{ STATIC_URL }}jquery.min.js"></script>
<script src="{{ STATIC_URL }}bootstrap.min.js"></script>
{% block includes %} {% endblock includes %}
</head>
<body>
<header>
<div id='left-header'>
{% block left-header %}
{% if user.is_authenticated %}
Team: {{user.team.team_name}}
</br>
<a href="/accounts/logout/">[Click here to logout]</a>
{% else %}
<p>Welcome Guest, Please <a href="/accounts/login/">log in</a> or <a href="/registration/">register.</a></p>
{% endif %}
{% endblock %}
</div>
<div id='right-header'>
{% block right-header %}
{% endblock %}
</div>
</header>
{% block content %}

{% endblock content %}

<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">PuzzlehuntCMU</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
{% block left-header %}
<li class='{% active_page request "index" %}'><a href="{% url 'huntserver:index' %}"> Puzzles </a></li>
{% if user.is_authenticated %}
<li class='{% active_page request "unlockables" %}'><a href="{% url 'huntserver:unlockables' %}"> Unlockables </a></li>
<li class='{% active_page request "chat" %}'><a href="{% url 'huntserver:chat' %}"> Chat </a></li>
{% else %}
<li><a href="/registration/">Register</a></li>
{% endif %}
{% endblock %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% block right-header %}
{% if user.is_authenticated %}
<p class="navbar-text">
Team: {{user.team.team_name}}
</p>
<a class="btn btn-default navbar-btn" href="/accounts/logout/">Log out</a>
{% else %}
<a class="btn btn-default navbar-btn" href="/accounts/login/">Log in</a>
{% endif %}
{% endblock %}
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
{% block content %} {% endblock content %}
</body>
</html>
35 changes: 18 additions & 17 deletions huntserver/templates/chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}huntserver/chat.css">
{% endblock includes %}

{% block right-header %} <a href='/'>Go back to all puzzles</a>{% endblock %}

{% block content %}
<div style="overflow: hidden; margin-bottom: 20px" >
<h1> Chat with staff </h1>
<p> Chatbox: </p>
<div style="padding: 15px;" id="chatcontainer">
{% for message in messages %}
{% if message.is_response %}
<div style='white-space:pre-wrap; color:red;'>Admin : {{ message.text }}</div>
{% else %}
<div style='white-space:pre-wrap;'>{{ team.team_name|slice:":10"|ljust:10 }}: {{ message.text }}</div>
{% endif %}
{% endfor %}
</div>
<div style="margin-top: 10px">
<input id="messagebox" typpe='text'> </input>
<button id="sendbutton">Send</button>
<div class="container">
<div class="row">
<div class="col-md-12 content">
<h1> Chat with staff </h1>
<div id="chatcontainer">
{% for message in messages %}
{% if message.is_response %}
<div style='white-space:pre-wrap; color:red;'>Admin : {{ message.text }}</div>
{% else %}
<div style='white-space:pre-wrap;'>{{ team.team_name|slice:":10"|ljust:10 }}: {{ message.text }}</div>
{% endif %}
{% endfor %}
</div>
<div style="margin-top: 10px">
<input id="messagebox" type='text'> </input>
<button id="sendbutton">Send</button>
</div>
</div>
</div>
</div>
<script type='text/javascript'>
Expand Down

0 comments on commit f361edf

Please sign in to comment.