V2EX foonpcf
 foonpcf's recent timeline updates
foonpcf

foonpcf

V2EX member #22752, joined on 2012-06-28 11:18:17 +08:00
foonpcf's recent replies
支持
Nov 25, 2014
Replied to a topic by foonpcf 问与答 有什方法可以查用什言呢?
=)
Sep 9, 2014
Replied to a topic by F2Sky iOS iOS 8 一出来你会第一时间升级么?
立即升
Aug 18, 2014
Replied to a topic by foonpcf 问与答 怎才能不透 SSH Mysql Server?
你的建。
因我正在Django目,所以期望能不透SSH能接另一的SQL server。
Aug 17, 2014
Replied to a topic by foonpcf 问与答 怎才能不透 SSH Mysql Server?
因我用Sequel Pro.
它用必需要我入 SSH HOST,User及密才可接。
Jun 28, 2014
Replied to a topic by foonpcf 问与答 像淘宝一的搜引擎
@YouXia 可以理用jQuery, 做到些分和倒排索引?
Jun 28, 2014
Replied to a topic by foonpcf 问与答 像淘宝一的搜引擎
@em70 我的不大,只是大5000本籍。
Jun 27, 2014
Replied to a topic by foonpcf 问与答 像淘宝一的搜引擎
只是想有一些,然後能,功能
May 19, 2014
Replied to a topic by foonpcf Python Python calendar .
@MasterYoda 我一整段代

from __future__ import with_statement
from cm.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from models import Event
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse

from calendar import HTMLCalendar, TimeEncoding, month_name, day_abbr

from django.utils.dates import MONTHS
from django.utils.dates import WEEKDAYS_ABBR

from datetime import date
from itertools import groupby

from django.utils.html import conditional_escape as esc

import locale

class EventCalendar(HTMLCalendar):
"""http://journal.uggedal.com/creating-a-flexible-monthly-calendar-in-django"""
def __init__(self, events):
super(EventCalendar, self).__init__()
self.events = self.group_by_day(events)

def formatday(self, day, weekday):
if day != 0:
cssclass = self.cssclasses[weekday]
if date.today() == date(self.year, self.month, day):
cssclass += ' today'
body = '<a class="tipsy" href="#" title="%s">%d</a>' % (_('Today'), day)
if day in self.events:
d = reverse('events_day', args=[self.year, self.month, day])
body = '<a class="tipsy" href="%s" title="%s">%d</a>' % (d, _("Events found"), day)
return self.day_cell(cssclass, body)

if day in self.events:
cssclass += ' filled'
title = ['<ul class=event>']
for event in self.events[day]:
title.append('<li><b>%s</b></li>' % esc(event.name))
title.append('</ul>')
d = reverse('events_day', args=(self.year, self.month, day))
body = '<a class="tipsy" href="%s" title="%s">%d</a>' % (d, _("Events found"), day)
return self.day_cell(cssclass, body)
return self.day_cell(cssclass, day)
return self.day_cell('noday', '&nbsp;')

def formatweekday(self, day):
return '<th class="%s">%s</th>' % (self.cssclasses[day], WEEKDAYS_ABBR[day].title())

def formatmonthname(self, theyear, themonth, withyear=True):
if withyear:
s = '%s %s' % (MONTHS[themonth].title(), theyear)
else:
s = '%s' % MONTHS[themonth].title()
return '<tr><th colspan="7" class="month">%s</th></tr>' % s

def formatmonth(self, year, month):
self.year, self.mOnth= year, month
return super(EventCalendar, self).formatmonth(year, month)

def group_by_day(self, events):
field = lambda event: event.start.day
return dict(
[(day, list(items)) for day, items in groupby(events, field)]
)

def day_cell(self, cssclass, body):
return '<td class="%s">%s</td>' % (cssclass, body)


class CMSCalendarEventsPlugin(CMSPluginBase):

name = _("Calendar Events")
render_template = "simple_events/events_calendar.html"

def render(self, context, instance, placeholder):
today = date.today()
year = today.year
mOnth= today.month

request = context['request']
if request.GET:
mOnth= int(request.GET.get('month') or month)
year = int(request.GET.get('year') or year)
first_day = date(year,month,1)
if mOnth== 12:
last_day = date(year+1,1,1)
else:
last_day = date(year,month+1,1)
events = Event.objects.filter(start__gte=first_day).filter(start__lt=last_day)
cal = EventCalendar(events).formatmonth(year, month)
context.update({'instance':instance,
'events': events,
'calendar': mark_safe(cal),
'placeholder':placeholder})
return context

plugin_pool.register_plugin(CMSCalendarEventsPlugin)
@h1994st 反而好奇遇到有力目,怎生力呢?我往往遇到情,是逃避。然後就.........一拖再拖....
About     Help     Advertise     Blog     API     FAQ     Solana     873 Online   Highest 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 21ms UTC 22:01 PVG 06:01 LAX 15:01 JFK 18:01
Do have faith in what you're doing.
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86