Permalink
Browse files

updates to models and templates

add more links into admin backend
show better informations on merge page
add icons for stats overview
  • Loading branch information...
1 parent 9269d0d commit 562c960e0cb3feb796c870d09b37a5acb89c77e9 @poelzi committed Jul 12, 2010
View
@@ -72,13 +72,13 @@ class Session(models.Model):
"""
start = models.DateTimeField("Start", null=False, auto_now_add=True, editable=False)
stop = models.DateTimeField("Stop", null=False, auto_now_add=True, editable=False)
- user = models.ForeignKey(User, null=True)
- detector = models.ForeignKey(Detector, null=True)
+ user = models.ForeignKey(User, null=True, blank=True)
+ detector = models.ForeignKey(Detector, null=True, blank=True)
typ = models.IntegerField("Type", default=0, choices=SESSION_TYPES)
- wakeup = models.DateTimeField("Wakeup", null=True)
- rating = models.IntegerField("Rating", null=True)
+ wakeup = models.DateTimeField("Wakeup", null=True, blank=True)
+ rating = models.IntegerField("Rating", null=True, blank=True)
deleted = models.BooleanField("Deleted", default=False)
- rf_id = models.IntegerField("RF Id", null=True)
+ rf_id = models.IntegerField("RF Id", null=True, blank=True)
closed = models.BooleanField("Session has ended", default=False)
objects = SessionManager()
@@ -112,6 +112,11 @@ def __unicode__(self):
entries = self.entry_set.all().count()
return u"Session from %s %s (%s:%0.2d) (%s Entries)" %(self.user, format(self.start, settings.DATETIME_FORMAT), length[0], length[1], entries)
+ @property
+ def entries_count(self):
+ return self.entry_set.all().count()
+
+
def merge(self, source):
source.entry_set.all().update(session=self)
source.learndata_set.all().delete()
@@ -169,6 +174,11 @@ class LearnData(models.Model):
help_text="When sleep stopped", null=True)
learned = models.BooleanField(default=False)
+ @property
+ def placed(self):
+ """Did the user set any points"""
+ return any((self.wake, self.lights, self.start, self.stop))
+
SIMPLICITI_PHASE_CLOCK_START_RESPONSE = 0x54
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -20,7 +20,9 @@
{% else %}
{% ifchanged session.week%}<h3>Week {{ session.start|date:"W" }}</h3>{% endifchanged %}
{% endif %}
-<a href="/stats/{{ session.id }}/" class="stats_detail">{{ session.start|date:"DATETIME_FORMAT" }} - {{ session.stop|date:"DATETIME_FORMAT" }} ({{session.length|timelengh}})</a><br/>
+<a href="/stats/{{ session.id }}/" class="stats_detail">{{ session.start|date:"DATETIME_FORMAT" }} - {{ session.stop|date:"DATETIME_FORMAT" }} ({{session.length|timelengh}})</a>
+ {% if session.learndata.placed %}<img src="/static/webclock/generic/marker.png" />{% endif %}
+ <br/>
{% endfor %}
{% block js_footer %}
@@ -32,6 +32,7 @@
<div id="moreactions">
<ul>
<li><a href="{% url admin:db_session_delete session.id %}">Delete</a></li>
+ <li><a href="{% url admin:db_session_change session.id %}">Edit</a></li>
{% if prev %}
<li><a href="{% url stats_merge session.id prev.id %}">Merge with Previous</a></li>
{% endif %}
@@ -113,6 +114,7 @@
last_index = 0;
skiped = 0;
$.each(data, function(index, value) {
+ /*
if((last > value.value) && (last - value.value > 100) ||
(last < value.value) && (value.value - last > 100)) {
if(skiped)
@@ -127,6 +129,8 @@
} else {
skiped = value;
}
+ */
+ Points.push([value.date, value.value, value.id]);
});
@@ -1,10 +1,14 @@
{% extends "base.html" %}
+{% load webclock %}
{% block content %}
<h1>Are you sure ?</h1>
You will merge session {{ source.id }} into {{ session.id }}.
This will destroy all aditional data known from the source session.
+<br />
+Source: {{ source.start|date:'DATETIME_FORMAT' }} - {{ source.stop|time }} ({{ source.length|timelengh }}) Entries: {{ source.entries_count }}<br/>
+Into: {{ session.start|date:'DATETIME_FORMAT' }} - {{ session.stop|time }} ({{ session.length|timelengh }})
<form method="POST" action="{% url stats_merge session.id source.id %}">
<input type="hidden" name="__confirm__" value="1" />{% csrf_token %}

0 comments on commit 562c960

Please sign in to comment.