本文整理汇总了Python中event.models.Event.description方法的典型用法代码示例。如果您正苦于以下问题:Python Event.description方法的具体用法?Python Event.description怎么用?Python Event.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类event.models.Event
的用法示例。
在下文中一共展示了Event.description方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addevent
# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import description [as 别名]
def addevent(request):
if request.method == 'POST':
eventform = EventForm(request.POST)
if eventform.is_valid():
event = Event()
event.event = eventform.cleaned_data['event']
event.startdate = eventform.cleaned_data['startdate']
event.enddate = eventform.cleaned_data['enddate']
event.organizer = eventform.cleaned_data['organizer']
event.description = eventform.cleaned_data['description']
event.email = eventform.cleaned_data['email']
event.website = eventform.cleaned_data['website']
event.affiche = eventform.cleaned_data['affiche']
event.save()
return HttpResponseRedirect('agenda')
else:
eventform = EventForm()
return render(request, 'event/addevent.html', locals())
示例2: handle
# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import description [as 别名]
def handle(self, *args, **options):
print "VK parsing..."
session = vk.Session(access_token=config.VK_API_TOKEN)
api = vk.API(session, v='5.40', lang='ru', timeout=100)
fields = ['place', 'description', 'members_count',
'start_date', 'end_date']
data = api.groups.search(q=options['q'],
type='event',
fields=','.join(fields),
count=self.count,
offset=self.offset,
future=1)
pp = pprint.PrettyPrinter(indent=1)
# pp.pprint(data)
if self.length == 0:
self.length = data['count']
for item in data['items']:
#pp.pprint(item)
event = Event()
event.site = 'VK'
event.lat = item['place']['latitude'] if 'place' in item else 0
event.lng = item['place']['longitude'] if 'place' in item else 0
if event.lat*event.lng == 0 :
continue
event.start_date = dt.fromtimestamp(item['start_date'], tz=pytz.utc) \
if 'start_date' in item else None
event.end_date = dt.fromtimestamp(item['end_date'], tz=pytz.utc) \
if 'end_date' in item else event.start_date + timedelta(hours=2)
event.title = item['name']
event.ext_id = item['id']
event.photo = item['photo_200'] if 'photo_200' in item else 0
event.description = item['description'] \
if 'description' in item else ''
event.member_count = item['members_count'] \
if 'members_count' in item else 0
event.create_or_update()
"""
event = {}
event['site'] = 'VK'
event['lat'] = item['place']['latitude'] if 'place' in item else 0
event['lng'] = item['place']['longitude'] if 'place' in item else 0
if event['lat']*event['lng'] == 0 :
continue
event['start_date'] = str(dt.fromtimestamp(item['start_date'], tz=pytz.utc).strftime('YYYY-MM-DD HH:MM')) \
if 'start_date' in item else ''
event['end_date'] = str(dt.fromtimestamp(item['end_date'], tz=pytz.utc).strftime('YYYY-MM-DD HH:MM')) \
if 'end_date' in item else ''
print event['start_date']
print event['end_date']
event['title'] = item['name']
event['ext_id'] = item['id']
event['photo'] = item['photo_200'] if 'photo_200' in item else 0
event['description'] = item['description'] \
if 'description' in item else ''
event['member_count'] = item['members_count'] \
if 'members_count' in item else 0
try:
save_event, created = Event.objects.update_or_create(**event)
# print save_event.get_external_url()
except Exception, e:
print e.message
"""
if self.length > 0:
self.offset += self.count
self.length -= self.count
time.sleep(0.5)
self.handle(**options)
else:
print("VK parse ends.")
示例3: handle
# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import description [as 别名]
def handle(self, *args, **options):
print "FB parsing..."
graph = facebook.GraphAPI(access_token=config.FB_API_TOKEN)
fields = [
'id',
'name',
'cover',
'description',
'start_time',
'end_time',
'place',
'attending_count',
'category',
]
data = graph.request(
"v2.5/search",
{
'q': options['q'],
'type': 'event',
'limit': self.count,
'since_date': 'currentTime',
'fields': ','.join(fields),
'after': '' if not 'after' in options else options['after'],
},
)
pp = pprint.PrettyPrinter(indent=1)
# pp.pprint(data)
for item in data['data']:
event = Event()
event.site = 'FB'
event.lat = 0
event.lng = 0
if 'place' in item:
event.lat = item['place']['location']['latitude'] \
if 'location' in item['place'] else 0
event.lng = item['place']['location']['longitude'] \
if 'location' in item['place'] else 0
if event.lat * event.lng == 0:
continue
if not 'start_time' in item:
continue
event.start_date = dateutil.parser.parse(item['start_time'])#dt.strptime(item['start_time'],'%Y-%m-%dT%H:%M:%S%Z')
event.end_date = dateutil.parser.parse(item['end_time']) \
if 'end_time' in item else event.start_date + timedelta(hours=2)
event.title = item['name']
event.ext_id = item['id']
event.photo = item['cover']['source'] \
if 'cover' in item else ''
event.description = item['description'] \
if 'description' in item else ''
event.member_count = item['attending_count'] \
if 'attending_count' in item else ''
event.category = item['category'] \
if 'category' in item else ''
event.create_or_update()
"""
event = {}
event['site'] = 'FB'
event['lat'] = 0
event['lng'] = 0
if 'place' in item:
event['lat'] = item['place']['location']['latitude'] \
if 'location' in item['place'] else 0
event['lng'] = item['place']['location']['longitude'] \
if 'location' in item['place'] else 0
if event['lat'] * event['lng'] == 0:
continue
event['start_date'] = item['start_time'] \
if 'start_time' in item else ''
event['end_date'] = item['end_time'] \
if 'end_time' in item else ''
event['title'] = item['name']
event['ext_id'] = item['id']
event['photo'] = item['cover']['source'] \
if 'cover' in item else ''
event['description'] = item['description'] \
if 'description' in item else ''
event['member_count'] = item['attending_count'] \
if 'attending_count' in item else ''
event['category'] = item['category'] \
if 'category' in item else ''
try:
save_event, created = Event.objects.update_or_create(**event)
# print save_event.get_external_url()
except Exception, e:
print e.message
pass
"""
if 'paging' in data:
# time.sleep(0.5)
options['after'] = data['paging']['cursors']['after']
self.handle(**options)
else:
print("FB parser ends.")
示例4: eventHandler
# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import description [as 别名]
def eventHandler(request, event_id=None):
if request.method == 'GET':
query = request.GET.get('query', None)
if query:
limit = 50
param = request.GET.get('param')
if param == "artist": # search events by artist name
events = Event.objects.select_related().prefetch_related().filter(artists__name__icontains=query).order_by("on_date")[:limit]
elif param == "combined":
try:
filter = request.GET.get('filter')
#print "date_from" , request.GET.get('date_from')
date_from = datetime.strptime(request.GET.get('date_from'), '%d-%m-%Y')
try:
date_to = datetime.strptime(request.GET.get('date_to'), '%d-%m-%Y')
except:
# day overflow , client maybe?
norm = request.GET.get('date_to')
n = "30-" + "-".join(norm.split("-")[1:])
date_to = datetime.strptime(n, '%d-%m-%Y')
towns = request.GET.get('towns', None)
qargs = Q()
qargs = qargs & Q(on_date__gte=date_from) & Q(on_date__lte=date_to)
if towns:
# PURE DARK MAGIC
towns = json.loads(towns)
t = Q()
for x in towns:
t |= Q(venue__city__icontains=x)
qargs &= t
if filter == "all":
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("on_date")[:limit]
elif filter == "recommended":
# needs better implementation
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("on_date")[:limit]
elif filter == "popular":
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("-attends", "on_date")[:limit]
elif filter == "free":
qargs &= Q(price=0.0)
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("on_date")[:limit]
except:
print traceback.format_exc()
stuff = serialize_events(events=events)
return HttpResponse(stuff, mimetype="application/json")
event_id = request.GET.get('event_id', None)
if event_id is None:
event_form = EventForm()
artist_form = ArtistForm()
venue_form = VenueForm()
return render_to_response('add_event.html', locals(), context_instance=RequestContext(request))
else:
#event = Event.objects.get(pk=event_id)#.select_related().prefetch_related().filter(pk=event_id)[0]
event = Event.objects.select_related().prefetch_related().get(pk=event_id)
#print "lele", event, event.name
#return render_to_response('poster_view.html', locals(), context_instance=RequestContext(request))
stuff = serialize_events(events=[event])
return HttpResponse(stuff, mimetype="application/json")
if request.method == 'POST':
try:
date = datetime.strptime(request.POST.get('date'), '%d-%m-%Y %H:%M')
#date = datetime.strptime(request.POST.get('date'), '%d-%m-%Y')
description = request.POST.get('description')
price = request.POST.get('price')
artist_ids = json.loads(request.POST.get('artist_ids'))
venue_id = request.POST.get('venue_id')
poster_id = request.POST.get('poster_id')
venue = Venue.objects.get(id=venue_id)
try:
user = STUser.objects.get(user=request.user)
except:
user = STUser.objects.get(user=request.session['user_id'])
possible_name = venue.name + "-" + str(date) + "_" + str(artist_ids[0])
# print "description", description, "poster_id", poster_id, "venue_id", venue_id
try:
Event.objects.filter(name=possible_name)[0]
return HttpResponse(json.dumps({"success":False}), mimetype="application/json")
except:pass
event = Event()
event._by = user.user.id
#.........这里部分代码省略.........