Пример #1
0
def get_in_progress_members(user):
  # Retrieve current tasks.
  in_progress_activity_members = get_current_activity_members(user)
  in_progress_commitment_members = get_current_commitment_members(user)
  return sorted(
    chain(in_progress_activity_members, in_progress_commitment_members),
    key=attrgetter("created_at"), reverse=True)
Пример #2
0
def get_in_progress_members(user):
    # Retrieve current tasks.
    in_progress_activity_members = get_current_activity_members(user)
    in_progress_commitment_members = get_current_commitment_members(user)
    return sorted(chain(in_progress_activity_members,
                        in_progress_commitment_members),
                  key=attrgetter("created_at"),
                  reverse=True)
Пример #3
0
def index(request):
  user = request.user
  form = None
  if request.method == "POST":
    user = request.user
    form = ProfileForm(request.POST, user=request.user)
    if form.is_valid():
      profile = user.get_profile()
      name = form.cleaned_data["display_name"].strip()
      
      if name != profile.name:
        profile.name = name

      profile.contact_email = form.cleaned_data["contact_email"]
      profile.contact_text = form.cleaned_data["contact_text"]
      profile.contact_carrier = form.cleaned_data["contact_carrier"]
      # profile.enable_help = form.cleaned_data["enable_help"]

      profile.save()
      form.message = "Your changes have been saved"
        
    else:
      form.message = "Please correct the errors below."
      
  # If this is a new request, initialize the form.
  if not form:
    profile = user.get_profile()
    form = ProfileForm(initial={
      # "enable_help": user.get_profile().enable_help,
      "display_name": profile.name,
      "contact_email": profile.contact_email or user.email,
      "contact_text": profile.contact_text,
      "contact_carrier": profile.contact_carrier,
    })
    
    if request.GET.has_key("changed_avatar"):
      form.message = "Your avatar has been updated."
  
  points_logs = user.pointstransaction_set.order_by("-submission_date").all()
  return render_to_response("view_profile/index.html", {
    "form": form,
    "in_progress_members": get_in_progress_members(user),
    "commitment_members": get_current_commitment_members(user),
    "points_logs": points_logs,
    # "notifications": user.usernotification_set.order_by("-created_at"),
  }, context_instance=RequestContext(request))
Пример #4
0
def index(request):
  floor_id = request.user.get_profile().floor_id
  
  # Get floor posts.
  posts = Post.objects.filter(
      floor=floor_id
  ).order_by("-id").select_related('user__profile')
  
  post_count = posts.count
  posts = posts[:DEFAULT_POST_COUNT]
  more_posts = True if post_count > DEFAULT_POST_COUNT else False
  
  # Get upcoming events.
  events = get_available_events(request.user)
  
  # Get the user's current commitments.
  commitment_members = get_current_commitment_members(request.user).select_related("commitment")
  
  # Get the floor members.
  floor_members = Profile.objects.filter(floor=floor_id).order_by(
      "-points", 
      "-last_awarded_submission"
  ).select_related('user')[:12]
  
  form = EventCodeForm()
    
  return render_to_response("news/index.html", {
    "posts": posts,
    "events": events,
    "wall_form": WallForm(),
    "more_posts": more_posts,
    "commitment_members": commitment_members,
    "floor_members": floor_members,
    "popular_tasks": get_popular_tasks(),
    "event_form":form,
  }, context_instance=RequestContext(request))