Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:svenstaro/flamejam
Browse files Browse the repository at this point in the history
  • Loading branch information
svenstaro committed Apr 19, 2013
2 parents 0bd0e36 + b60c4e3 commit e1a8f91
Show file tree
Hide file tree
Showing 44 changed files with 350 additions and 356 deletions.
2 changes: 0 additions & 2 deletions flamejam/forms.py
Expand Up @@ -216,8 +216,6 @@ class SettingsForm(Form):
notify_jam_start = BooleanField("when a jam I participate in starts")
notify_jam_finish = BooleanField("when a jam I participate in finishes")
notify_game_comment = BooleanField("when someone comments on a game of mine")
notify_team_changes = BooleanField("when another team member edits the team data")
notify_game_changes = BooleanField("when another team member edits the game data")
notify_team_invitation = BooleanField("when someone invites me to a team")

notify_newsletter = BooleanField("send me newsletters")
Expand Down
56 changes: 53 additions & 3 deletions flamejam/models/jam.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-

from flamejam import app, db
from flamejam import app, db, mail
from flamejam.utils import get_slug
from flamejam.filters import formattime, humandelta
from flamejam.models import Game
from datetime import datetime, timedelta
from flask import url_for, Markup
from flask import url_for, Markup, render_template
from random import shuffle

class Jam(db.Model):
Expand All @@ -28,7 +28,8 @@ class Jam(db.Model):
rating_duration = db.Column(db.Integer) # hours
duration = db.Column(db.Integer) # hours

last_notification_sent = db.Column(db.Integer, default = -1) # last notification that was sent, e.g. 0 = announcement, 1 = registration, (see status codes)
# last notification that was sent, e.g. 0 = announcement, 1 = registration, (see status codes)
last_notification_sent = db.Column(db.Integer, default = -1)

def __init__(self, title, start_time, duration = 48, team_limit = 0, theme = ''):
self.title = title
Expand Down Expand Up @@ -108,6 +109,55 @@ def getLink(self):
s += ' <span class="theme">%s</span>' % self.theme
return Markup(s)

def sendAllNotifications(self):
for n in range(self.last_notification_sent + 1, self.getStatus().code + 1):
self.sendNotification(n)

def sendNotification(self, n):
if not JamStatusCode.ANNOUNCED <= n <= JamStatusCode.FINISHED: return

kwargs = {}

if n == JamStatusCode.ANNOUNCED:
template = "announcement"
notify = "new_jam"
subject = "Jam announced: " + self.title
elif n == JamStatusCode.REGISTRATION:
template = "registration_start"
notify = "new_jam"
subject = "Registrations for " + self.title + " now open"
elif n == JamStatusCode.RUNNING:
template = "start"
notify = "jam_start"
subject = self.title + " starts now!"
elif n == JamStatusCode.PACKAGING:
template = "packaging_start"
notify = "jam_finish"
subject = self.title + " is over"
elif n == JamStatusCode.RATING:
template = "rating_start"
notify = "jam_finish"
subject = "Rating for " + self.title + " starts now"
elif n == JamStatusCode.FINISHED:
template = "finished"
notify = "jam_finish"
subject = "Rating for " + self.title + " finished - Winners"
kwargs = { "games": self.gamesByScore[:3] }

from flamejam.models import User
users = User.query
if n >= JamStatusCode.RUNNING and n != JamStatusCode.RATING:
users = self.users
users = users.filter("notify_" + notify)

for user in users:
body = render_template("emails/jam/" + template + ".txt", recipient=user, jam=self, **kwargs)
mail.send_message(subject=app.config["LONG_NAME"] + ": " + subject, recipients=[user.email], body=body)

self.last_notification_sent = n
db.session.commit()


class JamStatusCode(object):
ANNOUNCED = 0
REGISTRATION = 1
Expand Down
22 changes: 13 additions & 9 deletions flamejam/models/team.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from flamejam import app, db
from flamejam import app, db, mail
from flamejam.models import Invitation
from flask import url_for, render_template

Expand Down Expand Up @@ -90,12 +90,16 @@ def getInvitation(self, user):
return Invitation.query.filter_by(user_id = user.id, team_id = self.id).first()

def inviteUser(self, user, sender): # sender: which user sent the invitation
if self.getInvitation(user): i = self.getInvitation(user) # already invited
else: i = Invitation(self, user)
db.session.add(i)
db.session.commit()

c = render_template("emails/jam/invitation.html", team = self, sender = sender, recipient = user, invitation = i)
print c
#TODO
if not user.notify_team_invitation:
return None

if self.getInvitation(user):
i = self.getInvitation(user) # already invited
else:
i = Invitation(self, user)
db.session.add(i)
db.session.commit()
body = render_template("emails/invitation.txt", team=self, sender=sender, recipient=user, invitation=i)
mail.send_message(subject=app.config["LONG_NAME"] +": You have been invited to " + self.name, recipients=[user.email], body=body)
return i

2 changes: 0 additions & 2 deletions flamejam/models/user.py
Expand Up @@ -44,8 +44,6 @@ class User(db.Model):
notify_jam_start = db.Column(db.Boolean, default = True)
notify_jam_finish = db.Column(db.Boolean, default = True)
notify_game_comment = db.Column(db.Boolean, default = True)
notify_team_changes = db.Column(db.Boolean, default = True)
notify_game_changes = db.Column(db.Boolean, default = True)
notify_team_invitation = db.Column(db.Boolean, default = True)
notify_newsletter = db.Column(db.Boolean, default = True)

Expand Down
2 changes: 1 addition & 1 deletion flamejam/static/js/main.js
Expand Up @@ -102,5 +102,5 @@ $(document).ready(function() {
for (var i = 0; i < list.length; i++) {
list[i].parentNode.appendChild(list[i]);
}
})
});
});
6 changes: 6 additions & 0 deletions flamejam/static/js/map.js
Expand Up @@ -43,6 +43,12 @@ function addLocation(info) {
}

$(document).ready(function() {
// size and scrolling
var w = $(window), m = $("#map_canvas");
m.height(w.height() * 0.9);
$(window).scrollTop (m.offset().top + m.height() / 2 - w.height() / 2);
$(window).scrollLeft(m.offset().left + m.width() / 2 - w.width() / 2);

geocoder = new google.maps.Geocoder();

options = {
Expand Down
4 changes: 1 addition & 3 deletions flamejam/templates/account/settings.html
Expand Up @@ -51,9 +51,7 @@ <h2>Notification settings</h2>
<label class="checkbox">{{ form.notify_jam_start() }} {{ form.notify_jam_start.label.text }}</label>
<label class="checkbox">{{ form.notify_jam_finish() }} {{ form.notify_jam_finish.label.text }}</label>
<label class="checkbox">{{ form.notify_game_comment() }} {{ form.notify_game_comment.label.text }}</label>
<label class="checkbox">{{ form.notify_team_changes() }} {{ form.notify_team_changes.label.text }}</label>
<label class="checkbox">{{ form.notify_game_changes() }} {{ form.notify_game_changes.label.text }}</label>
<label class="checkbox">{{ form.notify_team_invitation() }} {{ form.notify_team_invitation.label.text }}</label>
<label class="checkbox">{{ form.notify_team_invitation() }} {{ form.notify_team_invitation.label.text }} <b>(important)</b></label>
<label class="checkbox">{{ form.notify_newsletter() }} {{ form.notify_newsletter.label.text }}</label>
</div>
<div class="field"></div>
Expand Down
8 changes: 0 additions & 8 deletions flamejam/templates/admin/announcement.html
Expand Up @@ -17,18 +17,10 @@ <h1>Write announcement</h1>
{{ form.message(rows = 10, id="announcement-message", class="announcement-input") }}
</div>
<div style="text-align: right;">
<span style="margin-right: 10px;">Parsed with markdown</span>
<input type="submit" class="btn btn-large" value="Send Announcement Now" />
</div>
</form>
</div>
<div class="span6">
<h3>Preview</h3>
<div id="announcement-preview"></div>
<script>
setInterval("updatePreview()", 2000);
</script>
</div>
</div>

{% endblock %}
2 changes: 1 addition & 1 deletion flamejam/templates/admin/jam.html
Expand Up @@ -136,7 +136,7 @@ <h2>Jam Notifications</h2>

<td>
{% if s == jam.last_notification_sent + 1 and status.code >= s %}
<a href="#">Send now</a>
<a href="{{ url_for('admin_jam_notification', id = jam.id, n = s) }}">Send now</a>
{% endif %}
</td>

Expand Down
4 changes: 1 addition & 3 deletions flamejam/templates/admin/users.html
Expand Up @@ -19,7 +19,6 @@ <h1>List of users</h1>
<th>Location</th>
<th>Flags</th>
<th></th>
<th></th>
</tr>
{% for user in users %}
<tr class="checkbox-toggle user-row">
Expand All @@ -44,11 +43,10 @@ <h1>List of users</h1>
{% endif %}
</td>
<td><a href="{{ user.url() }}">Show Profile</a></td>
<td><a href="{{ url_for('admin_user', username = user.username) }}">Merge</a></td>
</tr>
{% endfor %}
<tr>
<th colspan="9">
<th colspan="8">
<input type="submit" name="submit" value="Toggle Deleted" />
<input type="submit" name="submit" value="Toggle Admin" />
<span id="table-count">0</span> users selected
Expand Down
9 changes: 0 additions & 9 deletions flamejam/templates/emails/account/message.html

This file was deleted.

15 changes: 15 additions & 0 deletions flamejam/templates/emails/account/message.txt
@@ -0,0 +1,15 @@
{% extends "emails/base.txt" %}

{% block content %}
You received a message on BaconGameJam from {{ sender.username }}. Below is
this message. Note that this message is not sent from the BaconGameJam staff
but another user of the website. We are not responsible for it. You can reply
via eMail to <{{ sender.email }}>.

====== MESSAGE START ======
{{ message }}
====== MESSAGE END ======

If you don't want other users to be able to send you such messages, turn off the
"Allow PM" option on your profile settings page.
{% endblock %}
25 changes: 0 additions & 25 deletions flamejam/templates/emails/account/reset_password.html

This file was deleted.

11 changes: 11 additions & 0 deletions flamejam/templates/emails/account/reset_password.txt
@@ -0,0 +1,11 @@
{% extends "emails/base.txt" %}

{% block content %}
Hello {{ recipient.username }}, you requested a password reset.

To reset your password, please visit the following link:

{{ url_for('reset_verify', username=recipient.username, token=recipient.getResetToken(), _external=True) }}

If you did not request a password reset, please ignore this message.
{% endblock %}
32 changes: 0 additions & 32 deletions flamejam/templates/emails/account/verification.html

This file was deleted.

14 changes: 14 additions & 0 deletions flamejam/templates/emails/account/verification.txt
@@ -0,0 +1,14 @@
{% extends "emails/base.txt" %}

{% block content %}
Hello {{ recipient.username }}, {% if not email_changed %}welcome to BaconGameJam!{% endif %}

You have recieved this email to confirm your ownership of the email given during
signup for the user {{ recipient.username }}.

To verify your email address, please visit the following verification link:

{{ url_for('verify', username=recipient.username, verification=recipient.getVerificationHash(), _external=True) }}

If you received this email by error or did not {% if email_changed %}change your settings{% else %}register on bacongamejam.org{% endif %}, please ignore this email.
{% endblock %}
Empty file.
Empty file.
Empty file.
9 changes: 0 additions & 9 deletions flamejam/templates/emails/announcements/newsletter.html

This file was deleted.

Empty file.
Empty file.
Empty file.

0 comments on commit e1a8f91

Please sign in to comment.