本文整理汇总了Python中rapidsms.webui.utils.paginated函数的典型用法代码示例。如果您正苦于以下问题:Python paginated函数的具体用法?Python paginated怎么用?Python paginated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了paginated函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: site
def site(request, pk, template="weltel/site.html"):
context = {}
site = get_object_or_404(Site, id=pk)
patients = Patient.objects.filter(site=site)
nurses = Nurse.objects.filter(sites=site)
context['site'] = site
context['patients'] = paginated(request, patients)
context['nurses'] = paginated(request, nurses)
return render_to_response(request, template, context)
示例2: index
def index(request, template="weltel/index.html"):
context = {}
sites = Site.objects.all().order_by('name')
start_of_week = datetime.now()
# set to monday 00:00
start_of_week = start_of_week - timedelta(days=start_of_week.weekday(),
hours=start_of_week.hour,
minutes=start_of_week.minute)
for site in sites:
patients = Patient.objects.filter(site=site)
site.patient_count = patients.count()
site.nurse_count = Nurse.objects.filter(sites=site).count()
sawa_patients = patients.filter(state__code=SAWA_CODE)
shida_patients = patients.filter(state__code=SHIDA_CODE)
site.sawa_count = sawa_patients.count()
site.shida_count = shida_patients.count()
sawa_patients_this_week = sawa_patients.filter(active=True).filter(subscribed=True)
sawa_patients_this_week = sawa_patients_this_week.filter(eventlog__date__gte=start_of_week)
site.sawa_count_this_week = sawa_patients_this_week.distinct().count()
shida_patients_this_week = shida_patients.filter(active=True).filter(subscribed=True)
shida_patients_this_week = shida_patients_this_week.filter(eventlog__date__gte=start_of_week)
site.shida_count_this_week = shida_patients_this_week.distinct().count()
context['sites'] = paginated(request, sites)
#messages = EventLog.objects.select_related().order_by('-received')
#context.update( format_events_in_context(request, context, messages) )
return render_to_response(request, template, context)
示例3: patient_messages
def patient_messages(request, pk, template="weltel/patient.html"):
patient = get_object_or_404(Patient, id=pk)
context = {}
context['patient'] = patient
logs = get_messages_for_patient(patient)
context['messages'] = paginated(request, logs)
return render_to_response(request, template, context )
示例4: index
def index(req):
template_name = "childhealth/index.html"
surveyentries = SurveyEntry.objects.order_by("survey_date")
all = []
[all.append(entry) for entry in surveyentries]
# sort by date, descending
all.sort(lambda x, y: cmp(y.survey_date, x.survey_date))
assessments = ass_dicts_for_display()
# sort by date, descending
assessments.sort(lambda x, y: cmp(y["date"], x["date"]))
context = {}
context["entries"] = paginated(req, all, per_page=50)
context["assessments"] = paginated(req, assessments, per_page=50)
return render_to_response(req, template_name, context)
示例5: index
def index(req):
columns = (("name", "Point Name"),
("wqmarea", "Area"),
)
sort_column, sort_descending = _get_sort_info(req, default_sort_column="name",
default_sort_descending=False)
sort_desc_string = "-" if sort_descending else ""
search_string = req.REQUEST.get("q", "")
query = SamplingPoint.objects.order_by("%s%s" % (sort_desc_string, sort_column))
if search_string == "":
query = query.all()
else:
district = WqmAuthority.objects.get(id = search_string)
query = query.filter(
Q(wqmarea__wqmauthority__id=district.id ))
search_string = district
points = paginated(req, query)
return render_to_response(req,
"index.html", {
"columns": columns,
"points": points,
"districts": WqmAuthority.objects.all(),
"sort_column": sort_column,
"sort_descending": sort_descending,
"search_string": search_string,
})
示例6: index
def index(req):
# reporters = get_tester(req.user)
template_name = "testers/index.html"
columns = (("last_name", "Surname"),
("first_name", "Firstname"),
)
sort_column, sort_descending = _get_sort_info(req, default_sort_column="last_name",
default_sort_descending=False)
sort_desc_string = "-" if sort_descending else ""
search_string = req.REQUEST.get("q", "")
query = Reporter.objects.order_by("%s%s" % (sort_desc_string, sort_column))
if search_string == "":
query = query.all()
else:
query = query.filter(
Q(first_name__icontains=search_string) |
Q(last_name__icontains=search_string))
reporters = paginated(req, query)
# TODO: get the facility from the reporter profile
# and make if sortable.
profiles = ReporterProfile.objects.filter(domain=req.user.selected_domain)
return render_to_response(req, template_name, {"columns": columns,
"reporters": reporters,
"profiles": profiles,
"sort_column": sort_column,
"sort_descending": sort_descending,
"search_string": search_string})
示例7: get
def get(req):
# pre-populate the "connections" field
# with a connection object to convert into a
# reporter, if provided in the query string
connections = []
if "connection" in req.GET:
connections.append(
get_object_or_404(
PersistantConnection,
pk=req.GET["connection"]))
reporters = get_tester(req.user)
return render_to_response(req,
"testers/testers.html", {
# display paginated reporters in the left panel
"reporters": paginated(req, reporters),
# pre-populate connections
"connections": connections,
# list all groups + backends in the edit form
"all_groups": ReporterGroup.objects.flatten(),
"facilities": Facility.objects.filter(domain = req.user.selected_domain),
"all_backends": PersistantBackend.objects.all() })
示例8: index
def index(req):
template_name = "facilities/index_flat.html"
columns = (("added_date", "Date Added"), ("name", "Name"), ("location", "Location"), ("description", "Description"))
sort_column, sort_descending = _get_sort_info(req, default_sort_column="added_date", default_sort_descending=True)
sort_desc_string = "-" if sort_descending else ""
search_string = req.REQUEST.get("q", "")
query = Facility.objects.order_by("%s%s" % (sort_desc_string, sort_column))
if search_string == "":
query = query.all()
else:
query = query.filter(Q(name__icontains=search_string))
# Q(location__icontains=search_string))
facilities = paginated(req, query)
return render_to_response(
req,
template_name,
{
"columns": columns,
"facilities": facilities,
"sort_column": sort_column,
"sort_descending": sort_descending,
"search_string": search_string,
},
)
示例9: resource_history
def resource_history(req):
"""
display resources' history
"""
template_name = "resources/history.html"
columns = (("date", "Date Of Request"), ("name", "Name"), ("code", "Code"), ("Facility", "Current Location"))
# ("New", "Prev Location")) #previous location
sort_column, sort_descending = _get_sort_info(req, default_sort_column="date", default_sort_descending=True)
sort_desc_string = "-" if sort_descending else ""
search_string = req.REQUEST.get("q", "")
query = Resource.objects.order_by("%s%s" % (sort_desc_string, sort_column))
if search_string == "":
query = query.all()
else:
query = query.filter(Q(status__icontains=search_string) | Q(user__first_name__icontains=search_string))
history = paginated(req, query)
return render_to_response(
req,
template_name,
{
"columns": columns,
"history": history,
"sort_column": sort_column,
"sort_descending": sort_descending,
"search_string": search_string,
},
)
示例10: index
def index(req):
template_name="logger/index_flat.html"
columns = (("date", "Date"),
("connection__identity", "From/To"),
("connection__backend", "Backend"),
("is_incoming", "Direction"),
("text", "Message"))
sort_column, sort_descending = _get_sort_info(req, default_sort_column="date",
default_sort_descending=True)
sort_desc_string = "-" if sort_descending else ""
search_string = req.REQUEST.get("q", "")
query = Message.objects.select_related("connection", "connection__backend"
).order_by("%s%s" % (sort_desc_string, sort_column))
if search_string == "":
query = query.all()
else:
query = query.filter(
Q(text__icontains=search_string) |
Q(connection__identity__icontains=search_string))
messages = paginated(req, query)
return render_to_response(req, template_name, {"columns": columns,
"messages": messages,
"sort_column": sort_column,
"sort_descending": sort_descending,
"search_string": search_string})
示例11: index
def index(request):
template_name = "index.html"
notifications = SmsNotification.objects.all().order_by("-authorised_personnel")
return render_to_response(
request, template_name, {"notifications": paginated(request, notifications, prefix="smsnotice")}
)
示例12: patient
def patient(request, pk, template="weltel/patient.html"):
patient = get_object_or_404(Patient, id=pk)
context = {}
context['patient'] = patient
logs = get_history_for_patient(patient)
context['history'] = paginated(request, logs)
context['phone_numbers'] = [c.identity for c in patient.connections.all()]
return render_to_response(request, template, context )
示例13: get
def get(req):
template_name = "facilities/index.html"
facilities = Facility.objects.all().filter(domain=req.user.selected_domain)
locations = Location.objects.all()
return render_to_response(
req, template_name, {"facilities": paginated(req, facilities, prefix="facility"), "locations": locations}
)
示例14: location_type
def location_type(req, location_type_pk):
loc_type = get_object_or_404(
LocationType, pk=location_type_pk)
return render_to_response(req,
"locations/location-type.html", {
"active_location_type_tab": loc_type.pk,
"locations": paginated(req, loc_type.locations.all(), prefix="loc"),
"location_type": loc_type })
示例15: nurse
def nurse(request, pk, template="weltel/nurse.html"):
context = {}
nurse = get_object_or_404(Nurse, id=pk)
context['nurse'] = nurse
logs = nurse.messages(order_by='-received')
if logs:
context['logs'] = paginated(request, logs)
context['phone_numbers'] = [c.identity for c in nurse.connections.all()]
return render_to_response(request, template, context )