Exemple #1
0
def user_profile(request):
   try:
      if request.method =='POST':
         profileForm = EditUserForm(request.POST, instance=request.session['user_data'])
         if profileForm.is_valid():
            user = profileForm.save()
            request.session['user_data']=user
            Msg("Profile successfully updated", 1).push(request)
         if 'newbie' in request.GET:
            if 'login_redirect' in request.session:
               referrer = request.session['login_redirect']
               del request.session['login_redirect']
               return HttpResponseRedirect(referrer)
            else:
               return HttpResponseRedirect('/')
         
      else:
         profileForm = EditUserForm(instance=request.session['user_data'])
   
      dict = {'profileForm':profileForm}

   except KeyError:
      dict = {}
   
   return render_to_response(request, 'cal/user_profile.html', dict )
Exemple #2
0
def user_profile(request):
    try:
        if request.method == 'POST':
            profileForm = EditUserForm(request.POST,
                                       instance=request.session['user_data'])
            if profileForm.is_valid():
                user = profileForm.save()
                request.session['user_data'] = user
                Msg("Profile successfully updated", 1).push(request)
            if 'newbie' in request.GET:
                if 'login_redirect' in request.session:
                    referrer = request.session['login_redirect']
                    del request.session['login_redirect']
                    return HttpResponseRedirect(referrer)
                else:
                    return HttpResponseRedirect('/')

        else:
            profileForm = EditUserForm(instance=request.session['user_data'])

        dict = {'profileForm': profileForm}

    except KeyError:
        dict = {}

    return render_to_response(request, 'cal/user_profile.html', dict)
Exemple #3
0
def user_events(request, events_array, dict):
#                 all_my_events = [] 
#                 for all_rsvp in events_array: 
#                    all_my_events.append(all_rsvp.rsvp_event) 
#                 my_dates = [] 
#                 events_on_date = {}
#                 for event in all_my_events: 
#                    date_string = event.event_date_time_start.strftime("%A, %B %e") 
#                    if date_string not in my_dates: 
#                       my_dates.append(date_string)
#                       events_on_date[date_string] = [] 
#                    events_on_date[date_string].append(event) 
#                                                                                
#                 dict['all_my_dates'] = my_dates 
#                 dict['events_on_date'] = events_on_date       
	my_dates = []
	events_on_date = {}
	for rsvp in events_array:
		date_string = rsvp.rsvp_event.event_date_time_start.strftime("%A, %B %e")
		if date_string not in my_dates:
			my_dates.append(date_string)
			events_on_date[date_string] = []
		events_on_date[date_string].append((rsvp.rsvp_event,rsvp))

	dict['all_my_dates'] = my_dates
	dict['events_on_date'] = events_on_date
	dict['feat_opts'] = EventFeature.objects.all()  
	return render_to_response(request, 'cal/myevents.html', dict)                
Exemple #4
0
def user_invitations(request):
	dict = {}
	user = current_user(request)
	dict['pending_invites'] = RSVP.objects.filter(rsvp_user=user,rsvp_event__event_date_time_start__gte=datetime.now(),rsvp_type='Pending').order_by('rsvp_event__event_date_time_start')
	dict['accepted_invites'] = RSVP.objects.filter(rsvp_user=user,rsvp_type='Accepted',rsvp_referrer__isnull=False, rsvp_event__event_date_time_start__gte=datetime.now()).order_by('rsvp_event__event_date_time_start')
	dict['declined_invites'] = RSVP.objects.filter(rsvp_user=user,rsvp_type='Declined', rsvp_event__event_date_time_start__gte=datetime.now() ).order_by('rsvp_event__event_date_time_start')
	return render_to_response(request, 'cal/myinvites.html', dict)     
Exemple #5
0
def user_messages(request):
	dict = {}
	user = current_user(request)
	all_messages = UserMessage.objects.filter(um_user = user).order_by('um_date_posted').reverse()
	dict['unread_messages'] = UserMessage.objects.filter(um_user = user, um_date_read = None).order_by('um_date_posted').reverse()
	len(dict['unread_messages']) #Evaluate it now!
	dict['read_messages'] = UserMessage.objects.filter(um_user = user).exclude(um_date_read = None).order_by('um_date_posted').reverse()[0:5]
 	len(dict['read_messages']) #Evaluate it now!
	for msg in dict['unread_messages']:
	 	msg.mark_read()
	return render_to_response(request, 'cal/user_messages.html', dict)
Exemple #6
0
def user_messages(request):
    """
    no active link to this... we should replace my invites with my messages and move invites to my events
    """
    dict = {}
    user = current_user(request)
    all_messages = UserMessage.objects.filter(um_user = user).order_by('um_date_posted').reverse()
    dict['unread_messages'] = UserMessage.objects.filter(um_user = user, um_date_read = None).order_by('um_date_posted').reverse()
    len(dict['unread_messages']) #Evaluate it now!
    dict['read_messages'] = UserMessage.objects.filter(um_user = user).exclude(um_date_read = None).order_by('um_date_posted').reverse()[0:5]
    len(dict['read_messages']) #Evaluate it now!
    for msg in dict['unread_messages']:
         msg.mark_read()
    return render_to_response(request, 'cal/user_messages.html', dict)
Exemple #7
0
def profile(request, netid):
	try:
		user = User.objects.get(user_netid = netid)
	except:
		user = User.objects.filter(user_netid = netid)[1]
	dict = {}
	dict['user'] = user
	dict['bday_month'] = user.user_birthday.strftime("%B")
	dict['bday_year'] = user.user_birthday.year
	dict['bday_day'] = user.user_birthday.day
	
	if current_user(request) != user:
		pv = PageView()
		
		pv.view_viewer = current_user(request)
		pv.view_profile = user
		pv.view_datetime = datetime.now()
		
		pv.save()
	
	dict['view_count'] = PageView.objects.filter(view_profile = user).count()
	
	searchurl = "/search?"
	for key in FIELDMAP:
		cmd = '''val = user.%s''' % FIELDMAP[key]
		exec cmd
		dict['url'+FIELDMAP[key]] =  searchurl+urllib.urlencode({'f0':key,'q0':val})
	
	try:
		dict['major'] = DEPT_CODE[user.user_dept]
	except:
		dict['major'] = user.user_dept
	dict['abbrev_college'] = user.user_rescollege.replace(" Residential College", "")
	try:
		dict['full_state'] = STATE_CODE[user.user_homestate]
	except:
		dict['full_state'] = user.user_homestate
		
	dict['related_rescol'] = User.objects.filter(user_rescollege=user.user_rescollege).order_by('?')[:5]
	if user.user_dept in DEPT_CODE:
		dict['related_major'] = User.objects.filter(user_dept=user.user_dept).order_by('?')[:5]
	
	dict['birthday'] = searchurl+urllib.urlencode({'f0':'Birthday','q0':('-%d-%d' % (user.user_birthday.month,user.user_birthday.day))})
	dict['birthyear'] = searchurl+urllib.urlencode({'f0':'Birthday','q0':('%d-' % (user.user_birthday.year))})
	
	return render_to_response(request,'profile.html',dict)
Exemple #8
0
def user_messages(request):
    """
    no active link to this... we should replace my invites with my messages and move invites to my events
    """
    dict = {}
    user = current_user(request)
    all_messages = UserMessage.objects.filter(
        um_user=user).order_by('um_date_posted').reverse()
    dict['unread_messages'] = UserMessage.objects.filter(
        um_user=user, um_date_read=None).order_by('um_date_posted').reverse()
    len(dict['unread_messages'])  #Evaluate it now!
    dict['read_messages'] = UserMessage.objects.filter(um_user=user).exclude(
        um_date_read=None).order_by('um_date_posted').reverse()[0:5]
    len(dict['read_messages'])  #Evaluate it now!
    for msg in dict['unread_messages']:
        msg.mark_read()
    return render_to_response(request, 'cal/user_messages.html', dict)
Exemple #9
0
def form_email_attendees(request, event_id):
  """Show form for emailing attendees"""
  try:
  	myEvent = Event.objects.get(event_id=event_id)
  except:
  	return go_back(request, 'Error: No event found',0)
  attendee_count = myEvent.event_attendee_count
  user = current_user(request)
  if not myEvent.isAuthorizedModifier(user):
	Msg('Only an event administrator can use this feature to send emails to all attendees.',0).push(request)
	return HttpResponseRedirect('/events/%s' % event_id)
  elif attendee_count == 0:
	Msg('There are no confirmed attendees... yet!',0).push(request)
	return HttpResponseRedirect('/events/%s' % event_id)
  else:
	dict = {'event': myEvent}
	dict['whoscoming'] = RSVP.objects.filter(rsvp_event = myEvent, rsvp_type = 'Accepted')
	return render_to_response(request,"cal/email_attendees.html", dict)
Exemple #10
0
def activityFeed(request):
	user = current_user(request)
	if user.user_netid not in SITE_ADMINS:
		return HttpResponseRedirect('/')
	
	cutoff = datetime.now() - timedelta(hours = 48)
	
	feedItems = []
	
	userLogins = CalUser.objects.filter(user_last_login__gte=cutoff)
	for ul in userLogins:
		feedItems.append((ul.user_last_login,'%s: %s logged in' % (ul.user_last_login.strftime("%d/%m/%y %I:%M%p"),ul.full_name_suffix())))
	
	clusterCreated = EventCluster.objects.filter(cluster_date_time_created__gte=cutoff)
	for cc in clusterCreated:
		feedItems.append((cc.cluster_date_time_created,'%s: %s created event cluster \'%s\'' % (cc.cluster_date_time_created.strftime("%d/%m/%y %I:%M%p"),cc.cluster_user_created.full_name_suffix(), cc.cluster_title)))
	
	bMessages = BoardMessage.objects.filter(boardmessage_time_posted__gte = cutoff)
	for bm in bMessages:
		feedItems.append((bm.boardmessage_time_posted,'%s: %s posted a message to event cluster \'%s\'' % (bm.boardmessage_time_posted.strftime("%d/%m/%y %I:%M%p"),bm.boardmessage_poster.full_name_suffix(), bm.boardmessage_eventcluster.cluster_title)))
		
	rsvps = RSVP.objects.filter(rsvp_date_created__gte=cutoff)
	for rsvp in rsvps:
		if rsvp.rsvp_referrer:
			feedItems.append((rsvp.rsvp_date_created,'%s: %s has a %s RSVP to event \'%s\' from %s' % (rsvp.rsvp_date_created.strftime("%d/%m/%y %I:%M%p"),rsvp.rsvp_user.full_name_suffix(), rsvp.rsvp_type, rsvp.rsvp_event.displayname(), rsvp.rsvp_referrer.full_name_suffix())))		
		else:
			feedItems.append((rsvp.rsvp_date_created,'%s: %s has a %s RSVP to event \'%s\'' % (rsvp.rsvp_date_created.strftime("%d/%m/%y %I:%M%p"),rsvp.rsvp_user.full_name_suffix(), rsvp.rsvp_type, rsvp.rsvp_event.displayname())))		
	
	views = View.objects.filter(view_date_time__gte=cutoff)
	for v in views:
		feedItems.append((v.view_date_time,'%s: %s viewed \'%s\' for the %s time' % (v.view_date_time.strftime("%d/%m/%y %I:%M%p"),v.view_viewer.full_name_suffix(), v.view_event.displayname(),v.view_count)))
		
	
	feedItems = sorted(feedItems, key=lambda item: item[0], reverse=True)
	
	dict = {}
	dict['happenings'] = feedItems
	
	return render_to_response(request, 'cal/easteregg.html', dict)
Exemple #11
0
def search(request):
	max_page = 50
	dict = {}
	disabled = ['Suffix','Mailbox']
	keys = filter(lambda x: x not in disabled, FIELDMAP.keys())
	dict['fields'] = FIELDMAP.keys()
	dict['ac_field'] = keys
	if request.method == 'GET' and len(request.GET) > 1:
		page = int(request.GET.get('p', 1))
		results,fields = searchResults(request)
		dict['results_count'] = results.count()		
		dict['results'] = results[((page-1)*max_page):min(((page)*max_page),results.count())]
		dict['result_start_count'] = ((page-1)*max_page)+1
		dict['result_end_count'] = min(((page)*max_page),results.count())
		dict['selected_fields'] = fields
		if (page)*max_page < results.count():
			ndict = copy.deepcopy(request.GET)
			ndict['p'] = page+1
			dict['page_next'] = urllib.urlencode(ndict)
		if (page-1)*max_page > 0:
			pdict = copy.deepcopy(request.GET)
			pdict['p'] = page-1
			dict['page_prev'] = urllib.urlencode(pdict)
	return render_to_response(request,'search.html',dict)
Exemple #12
0
 def GET(self, *args, **kwargs):
     i = web.input()
     if not i or i.get('ajax',0)==0:
         c = {'title': u"Заголовок"}
         c['sortList'] = SORT_LIST
         c['DBDate'] = datetime.fromtimestamp(os.stat(APP_PATH+'/tm/ardj.sqlite')[8])
         query_r = fetchQuery("SELECT label, COUNT(track_id) AS tc FROM labels WHERE NOT label LIKE '%%:%%' GROUP BY label ORDER BY tc DESC LIMIT 20")
         c['labels'] = sorted([one[0] for one in query_r or []])
         query_r = fetchQuery("SELECT DISTINCT label FROM labels WHERE NOT label LIKE '%%:%%'")
         c['allLabels'] = sorted([one[0] for one in query_r or [] if one[0]])
         c['tracksCount'] = fetchQuery("SELECT COUNT(*) FROM tracks WHERE weight>0")[0][0]
         c['setSearchData'] = ''
         if self.get_argument('permalink','1') == '1':
             data = json.dumps(self.getSearchData())
             c['setSearchData'] = u"""
                 var searchDataSet = $.parseJSON('%s');
                 showInfo(searchDataSet);
             """%data
             print c['setSearchData']
         return render_to_response("tmbase.html", c)
     else:
         data = self.getSearchData()
         jsonData = json.dumps(data)
         return jsonData
Exemple #13
0
def user_admin_events(request):
	user = current_user(request)
	dict = {}
	dict['tabtitle'] = "%s's Created Events" % (user.user_firstname)
	array = Event.objects.exclude(event_date_time_start=dtdeleteflag).filter(event_cluster__cluster_user_created=current_user(request)).order_by('event_date_time_start')
	my_dates = []
	events_on_date = {}
	usr = current_user(request)
	for event in array:
		date_string = event.event_date_time_start.strftime("%A, %B %e")
		if date_string not in my_dates:
			my_dates.append(date_string)
			events_on_date[date_string] = []
		if usr:	
			try:
				events_on_date[date_string].append((event,RSVP.objects.get(rsvp_event = event, rsvp_user = usr)))
			except:
				events_on_date[date_string].append((event,None))
		else:
			events_on_date[date_string].append((event,None))
	dict['all_my_dates'] = my_dates
	dict['events_on_date'] = events_on_date
	dict['feat_opts'] = EventFeature.objects.all()  
	return render_to_response(request, 'cal/myevents.html', dict)
Exemple #14
0
def autocomplete(request, fieldname):
	dict = {}
	if fieldname in FIELDMAP:
		dict['items'] = sorted(getListOfVals(FIELDMAP[fieldname]))
	return render_to_response(request,'jsonlist',dict)
Exemple #15
0
def nocookie(request):
	dict = {}
	return render_to_response(request, 'cal/nocookie.html', dict)
Exemple #16
0
def user_messages_hover(request):
	dict = {}
	user = current_user(request)
	dict['unread_messages'] = UserMessage.objects.filter(um_user = user, um_date_read = None).order_by('um_date_posted').reverse()
	Msg('You just loaded a tooltip!',1).push(request)
	return render_to_response(request, 'cal/hover_messages.html', dict)