-
Notifications
You must be signed in to change notification settings - Fork 568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAMBRO Home Page Update (index.html) #1100
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,63 @@ | |
import simplejson as json # try external module | ||
except: | ||
import gluon.contrib.simplejson as json # fallback to pure-Python module | ||
|
||
from gluon import current | ||
from gluon.html import * | ||
from gluon.storage import Storage | ||
|
||
from s3 import S3LocationFilter, S3OptionsFilter, S3FilterForm, S3CustomController | ||
|
||
THEME = "CAP" | ||
THEME = "SAMBRO" | ||
|
||
# ============================================================================= | ||
class index(S3CustomController): | ||
""" Custom Home Page """ | ||
|
||
def __call__(self): | ||
response = current.response | ||
s3 = response.s3 | ||
T = current.T | ||
|
||
map = current.gis.show_map() | ||
|
||
output = {} | ||
output["map"] = map | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these are right after one another then slightly more efficient to do the 2 together: |
||
|
||
# Image Carousel | ||
# Latest 4 Events and Alerts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that in the code you're copying from, these are both just types of cms_post, yet in SAMBRO an alert should be a cap_alert, no? |
||
from s3.s3query import FS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We normally prefer to just import from the main s3 module (this may have been wrong in the code you copy/pasted) |
||
s3db = current.s3db | ||
layout = s3.render_posts | ||
list_id = "news_datalist" | ||
limit = 4 | ||
list_fields = ["series_id", | ||
"location_id", | ||
"date", | ||
"body", | ||
"created_by", | ||
"created_by$organisation_id", | ||
"document.file", | ||
"event_post.event_id", | ||
] | ||
|
||
resource = s3db.resource("cms_post") | ||
resource.add_filter(FS("series_id$name") == "Event") | ||
# Only show Future Events | ||
resource.add_filter(resource.table.date >= current.request.now) | ||
# Order with next Event first | ||
orderby = "date" | ||
output["events"] = latest_records(resource, layout, list_id, limit, list_fields, orderby) | ||
|
||
resource = s3db.resource("cms_post") | ||
resource.add_filter(FS("series_id$name") == "Alert") | ||
# Order with most recent Alert first | ||
orderby = "date desc" | ||
output["alerts"] = latest_records(resource, layout, list_id, limit, list_fields, orderby) | ||
|
||
|
||
self._view(THEME, "index.html") | ||
|
||
return output | ||
|
||
# ============================================================================= | ||
class subscriptions(S3CustomController): | ||
|
@@ -37,8 +86,7 @@ def __call__(self): | |
# Available resources | ||
resources = [dict(resource="cap_alert", | ||
url="cap/alert", | ||
label=T("Updates")), | ||
] | ||
label=T("Updates")),] | ||
|
||
# Filter widgets | ||
# @note: subscription manager has no resource context, so | ||
|
@@ -49,23 +97,19 @@ def __call__(self): | |
options = s3db.cap_info_category_opts, | ||
represent = "%(name)s", | ||
resource = "cap_info", | ||
_name = "category-filter", | ||
), | ||
_name = "category-filter",), | ||
S3LocationFilter("location_id", | ||
label = T("Location(s)"), | ||
levels = ("L0",), | ||
resource = "cap_area_location", | ||
options = gis.get_countries().keys(), | ||
_name = "location-filter", | ||
), | ||
_name = "location-filter",), | ||
S3OptionsFilter("language", | ||
label = T("Language"), | ||
options = settings.get_cap_languages(), | ||
represent = "%(name)s", | ||
resource = "cap_info", | ||
_name = "language-filter", | ||
), | ||
] | ||
_name = "language-filter",),] | ||
|
||
# Title and view | ||
title = T("Notification Settings") | ||
|
@@ -91,20 +135,16 @@ def _manage_subscriptions(self, resources, filters): | |
|
||
# L10n | ||
T = current.T | ||
labels = Storage( | ||
RESOURCES = T("Subscribe To"), | ||
labels = Storage(RESOURCES = T("Subscribe To"), | ||
NOTIFY_ON = T("Notify On"), | ||
FREQUENCY = T("Frequency"), | ||
NOTIFY_BY = T("Notify By"), | ||
MORE = T("More Options"), | ||
LESS = T("Less Options"), | ||
) | ||
messages = Storage( | ||
ERROR = T("Error: could not update notification settings"), | ||
SUCCESS = T("Notification settings updated"), | ||
) | ||
|
||
# Get current subscription settings resp. form defaults | ||
LESS = T("Less Options"),) | ||
messages = Storage(ERROR = T("Error: could not update notification settings"), | ||
SUCCESS = T("Notification settings updated"),) | ||
|
||
# Get current subscription settings resp. form defaults | ||
subscription = self._get_subscription() | ||
|
||
# Formstyle bootstrap | ||
|
@@ -320,8 +360,7 @@ def _update_subscription(self, subscription): | |
method=subscription["method"]) | ||
subscription_id = success | ||
else: | ||
success = db(stable.id == subscription_id).update( | ||
pe_id=pe_id, | ||
success = db(stable.id == subscription_id).update(pe_id=pe_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're going to tweak all this whitespace then please sort indents |
||
filter_id=filter_id, | ||
notify_on=subscription["notify_on"], | ||
frequency=frequency, | ||
|
@@ -397,4 +436,42 @@ def _update_subscription(self, subscription): | |
subscription["filter_id"] = filter_id | ||
return subscription | ||
|
||
# ============================================================================= | ||
def latest_records(resource, layout, list_id, limit, list_fields, orderby): | ||
""" | ||
Display a dataList of the latest records for a resource | ||
@todo: remove this wrapper | ||
""" | ||
|
||
#orderby = resource.table[orderby] | ||
datalist, numrows, ids = resource.datalist(fields=list_fields, | ||
start=None, | ||
limit=limit, | ||
list_id=list_id, | ||
orderby=orderby, | ||
layout=layout) | ||
if numrows == 0: | ||
# Empty table or just no match? | ||
from s3.s3crud import S3CRUD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from s3 import S3CRUD (probably copy/pasted, I know) |
||
table = resource.table | ||
if "deleted" in table: | ||
available_records = current.db(table.deleted != True) | ||
else: | ||
available_records = current.db(table._id > 0) | ||
if available_records.select(table._id, | ||
limitby=(0, 1)).first(): | ||
msg = DIV(S3CRUD.crud_string(resource.tablename, | ||
"msg_no_match"), | ||
_class="empty") | ||
else: | ||
msg = DIV(S3CRUD.crud_string(resource.tablename, | ||
"msg_list_empty"), | ||
_class="empty") | ||
data = msg | ||
else: | ||
# Render the list | ||
data = datalist.html() | ||
|
||
return data | ||
|
||
# END ========================================================================= |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
../themes/default/layout.css | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If all you need is a little extra CSS for the homepage then moving to a full theme probably isn't required (a lot more maintenance effort). |
||
../themes/default/footer.css | ||
../themes/default/widgets.css | ||
../themes/default/shortcut.css | ||
../themes/default/homepage.css | ||
bootstrap/font-awesome.css | ||
plugins/jquery.cluetip.css | ||
plugins/jquery.dataTables.css | ||
plugins/jquery.dataTables.responsive.css | ||
#ui/accordion.css | ||
ui/core.css | ||
ui/autocomplete.css | ||
ui/button.css | ||
ui/datepicker.css | ||
ui/dialog.css | ||
# Needed for Delphi | ||
ui/draggable.css | ||
ui/menu.css | ||
#ui/progressbar.css | ||
ui/resizable.css | ||
ui/selectmenu.css | ||
ui/slider.css | ||
#ui/sortable.css | ||
#ui/spinner.css | ||
ui/tabs.css | ||
#ui/tooltip.css | ||
ui/fgtimepicker.css | ||
ui/multiselect.css | ||
ui/timepicker-addon.css | ||
calendars/ui-smoothness.calendars.picker.css | ||
foundation/jquery-ui.theme.css | ||
gis/style.css | ||
zocial/zocial.css | ||
../themes/default/gis.css | ||
../themes/foundation/map.css | ||
../themes/default/mobile.css | ||
../themes/default/print.css | ||
d3/nv.d3.css | ||
../themes/default/report.css | ||
../themes/default/survey.css | ||
../themes/SAMBRO/style.css | ||
# Final line required for parsing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{{extend "layout.html"}}{{theme=response.s3.theme}} | ||
<link href="/eden/static/styles/../themes/SAMBRO/style.css" rel="stylesheet" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to do this via s3.stylesheets, as I explained |
||
|
||
<div id="sambro-body" class="row"> | ||
<div class="large-12 columns"> | ||
<div class="row"> | ||
|
||
<div id="sambro-left" class="large-2 small-3 columns"> | ||
<div class="sambro-panel"> | ||
<h4><i class="icon icon-bullhorn"></i>{{=T("Alerts")}}</h4> | ||
<div class="sambro-list"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a for item in list_of_items: etc no? |
||
<i class="icon icon-compass"></i><a href="alert">Alert Title 1</a> | ||
</div> | ||
<div class="sambro-list"> | ||
<i class="icon icon-compass"></i><a href="alert">Alert Title 2</a> | ||
</div> | ||
<div class="sambro-list"> | ||
<i class="icon icon-compass"></i><a href="alert">Alert Title 3</a> | ||
</div> | ||
<div class="sambro-list"> | ||
<i class="icon icon-compass"></i><a href="alert">Alert Title 4</a> | ||
</div> | ||
<div class="sambro-list"> | ||
<i class="icon icon-compass"></i><a href="alert">Alert Title 5</a> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div id="sambro-center" class="large-8 small-9 columns"> | ||
<div class="sambro-panel"> | ||
<h4>{{=T("Sahana Alert System")}}</h4> | ||
{{=XML(map)}} | ||
</div> | ||
</div> | ||
|
||
<div id="sambro-right" class="large-2 small-12 columns"> | ||
<div class="sambro-panel"> | ||
<h4>{{=T("Events")}}</h4> | ||
<div class="sambro-list"> | ||
{{=events}} | ||
</div> | ||
</div> | ||
<div class="sambro-panel"> | ||
<h4>{{=T("Feeds")}}</h4> | ||
<div class="sambro-list"> | ||
{{=alerts}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$(document).ready(function () { | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
body { | ||
background-color: #FAFAFA; | ||
} | ||
|
||
.icon { | ||
margin-right: 5px; | ||
} | ||
|
||
#sambro-body { | ||
} | ||
|
||
#sambro-center { | ||
} | ||
|
||
.sambro-list { | ||
padding: 5px 5px; | ||
} | ||
|
||
.sambro-panel { | ||
background-color: #FFF; | ||
margin: 20px 0px 0px 0px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is responsive is it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is responsive. I am using "row" and "column" in the html. The css above is for formatting only, adding some paddings and margin, doesn't have to do with layout. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. margins and paddings are fine, although Foundation recommends to use rem instead of px as that would make them adapt to font scaling ;) |
||
border: 1px solid #e7eaec; | ||
border-top: 4px solid #e7eaec; | ||
} | ||
|
||
.sambro-panel div { | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty? So better to remove? |
||
|
||
.sambro-panel h4 { | ||
border-bottom: 1px solid #DDD; | ||
font-size: 16px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rem is recommended as it allows scaling (mobile devices often do auto-scaling of fonts) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok... thanks. |
||
color: #888; | ||
margin: 0px; | ||
padding: 0px; | ||
padding: 10px 10px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid such whitespace changes - the existing style was the one used in all the other code