cal: span events across weeks
authorTero Marttila <terom@fixme.fi>
Sat, 08 Jan 2011 23:41:48 +0200
changeset 40 30a0a0fa8c54
parent 39 4f331cfc76a4
child 41 36d029a47d37
cal: span events across weeks
static/cal.css
svv/cal.py
--- a/static/cal.css	Sat Jan 08 23:17:16 2011 +0200
+++ b/static/cal.css	Sat Jan 08 23:41:48 2011 +0200
@@ -63,7 +63,7 @@
 }
 
 /* Each event is visible as its own block */
-table.calendar tbody tr.week-data td.event a
+table.calendar td.event a
 {
     display: block;
 
@@ -78,6 +78,52 @@
     text-align: center;
 }
 
+/* An event that also continues on the following week has a straight right border */
+table.calendar td.continues-next a
+{
+    border-top-right-radius: 0px;
+    border-bottom-right-radius: 0px;
+    
+    -moz-border-radius-topright: 0px;
+    -moz-border-radius-bottomright: 0px;
+}
+
+/* An event that also continues on the previous week has a straight left border */
+table.calendar td.continues-prev a
+{
+    border-top-left-radius: 0px;
+    border-bottom-left-radius: 0px;
+    
+    -moz-border-radius-topleft: 0px;
+    -moz-border-radius-bottomleft: 0px;
+}
+
+/* Fake arrow using borders */
+table.calendar div.arrow-right,
+table.calendar div.arrow-left
+{
+    display: inline;
+
+    font-size: 0px; line-height: 0%; width: 0px;
+
+    border-top: 6px solid #A6C6E3; /* Background */
+    border-bottom: 6px solid #A6C6E3; /* Background */
+}
+
+table.calendar div.arrow-right
+{
+    float: right;
+
+    border-left: 6px solid #ffffff; /* Arrow color */
+}
+
+table.calendar div.arrow-left
+{
+    float: left;
+
+    border-right: 6px solid #ffffff; /* Arrow color */
+}
+
 /* Borders ? */
 table.calendar tbody td
 {
--- a/svv/cal.py	Sat Jan 08 23:17:16 2011 +0200
+++ b/svv/cal.py	Sat Jan 08 23:41:48 2011 +0200
@@ -161,12 +161,24 @@
             length = (end - start).days + 1
             trailing = (max(week) - end).days
 
+            # continues prev/next?
+            prev = (start > order.event_start.date())
+            next = (end < order.event_end.date())
+
             log.debug("Event %r from %r -> %r", order.event_name, start, end)
 
             yield tags.tr(class_='week-data')(
                 [tags.td("")] * leading,
-                tags.td(colspan=length, class_='event')(
-                    tags.a(href=self.url_for(urls.OrderView, id=order.id))(order.event_name)
+                tags.td(colspan=length, class_=(' '.join(cls for cls in (
+                    'event',
+                    'continues-prev' if prev else None,
+                    'continues-next' if next else None,
+                ) if cls)))(
+                    tags.a(href=self.url_for(urls.OrderView, id=order.id))(
+                        tags.div(class_='arrow-left')("") if prev else None,
+                        order.event_name,
+                        tags.div(class_='arrow-right')("") if next else None,
+                    )
                 ),
                 [tags.td("")] * trailing,
             )