def profile(request, username): user = get_object_or_404(User, username__iexact = username) if request.is_ajax(): queryset = Message.objects.get_conversation_between(user, request.user) paginator = Paginator(queryset, 10) page = request.GET.get('page') try: message_list = paginator.page(page) except PageNotAnInteger: raise Http404 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. message_list = paginator.page(paginator.num_pages) return render_to_response('umessages/conversation.html',{'message_list': message_list}) else: extra_context = dict() extra_context['followers'] = ActStream.followers(user) extra_context['followings'] = ActStream.following(user) extra_context['recipe_list'] = list(user.recipe_set.all().only('name', 'cover_image', 'did_num', 'like_num', 'date', 'view_num')) extra_context['favourite_list'] = list(user.get_profile().favourite_recipes.all().only('name', 'cover_image', 'did_num', 'like_num', 'date', 'view_num')) extra_context['form'] = MugshotForm() extra_context['public_messages'] = list(Message.objects.get_public_messages(to_user = user)) extra_context['recommends'] = list(recommendations.recommendRecipeForUser(user.id, 10)) extra_context['did_recipe_list'] = list(DidRecipe.objects.filter(user = user).select_related('recipe').only('image', 'date', 'recipe__name')) response = profile_detail(request, username, extra_context = extra_context) return response
def profile_detail(request, username): """ Build a list of projects that matches, if possible, the language of the viewer. If not possible, fall back to english, and if not available, first language. """ user = get_object_or_404(User, username__iexact=username) project_member_list = user.projects.all() workgroup_member_list = user.workgroups.all() project_translation_ct = ContentType.objects.get_for_model(I4pProject) # FIXME : UGLY AND DOESN'T WORK ! version_ids = [int(id["object_id"]) for id in Version.objects.filter(content_type=project_translation_ct, revision__user=user).values('object_id').distinct()[:30]] project_contrib_list = I4pProject.objects.filter(id__in=version_ids) project_fan_list = I4pProject.objects.filter(fans__id=user.id) return userena_views.profile_detail(request, username, template_name='userena/profile_detail.html', extra_context={'project_member_list': project_member_list, 'workgroup_member_list': workgroup_member_list, 'project_contrib_list' : project_contrib_list, 'project_fan_list' : project_fan_list} )
def profile_detail(request, username): """ Build a list of projects that matches, if possible, the language of the viewer. If not possible, fall back to english, and if not available, first language. """ user = get_object_or_404(User, username__iexact=username) project_translation_list = get_project_translations_from_parents( user.projects.all().distinct()[:3], language_code=translation.get_language() ) project_translation_ct = ContentType.objects.get_for_model(I4pProjectTranslation) # FIXME : UGLY AND DOESN'T WORK ! version_ids = [ int(id["object_id"]) for id in Version.objects.filter(content_type=project_translation_ct, revision__user=user) .values("object_id") .distinct()[:30] ] project_contrib_list = I4pProjectTranslation.objects.filter(id__in=version_ids) return userena_views.profile_detail( request, username, template_name="userena/profile_detail.html", extra_context={ "project_translation_list": project_translation_list, "project_contrib_list": project_contrib_list, }, )
def profile_detail(request, username): """ Build a list of projects that matches, if possible, the language of the viewer. If not possible, fall back to english, and if not available, first language. """ user = get_object_or_404(User, username__iexact=username) project_translation_list = get_project_translations_from_parents( user.projects.all().distinct()[:3], language_code=translation.get_language()) project_translation_ct = ContentType.objects.get_for_model( I4pProjectTranslation) # FIXME : UGLY AND DOESN'T WORK ! version_ids = [ int(id["object_id"]) for id in Version.objects.filter(content_type=project_translation_ct, revision__user=user).values( 'object_id').distinct()[:30] ] project_contrib_list = I4pProjectTranslation.objects.filter( id__in=version_ids) return userena_views.profile_detail( request, username, template_name='userena/profile_detail.html', extra_context={ 'project_translation_list': project_translation_list, 'project_contrib_list': project_contrib_list })
def get(self, request, *args, **kwargs): user = User.objects.get_by_natural_key(kwargs.get('username')) if not hasattr(user.profile, 'intern'): raise PermissionDenied kwargs['template_name'] = self.get_template_name(user) return profile_detail(request, *args, **kwargs)
def detail(request, username): if request.user.username == username: return redirect('account:dashboard') else: user = get_object_or_404(User, username=username) today = date.today() # month_gigbargains = GigBargain.objects.filter(bands__in=user.bands.all, date__year=today.year, date__month=today.month).order_by('date') # band_connections = Band.objects.filter(gigbargains__in=month_gigbargains).exclude(pk__in=user.bands.all).distinct() # user_connections = User.objects.filter(bands__in=band_connections).distinct()[:20] return profile_detail(request, username, template_name='userena/profile_detail.html', #extra_context={'user_connections': user_connections} )
def profile_detail(request, username, *args, **kwargs): user = get_object_or_404(User, username__iexact=username) try: profile = user.get_profile() except Exception: profile = FdProfile(user=user) profile.save() context = {'events': get_events(profile)} return userena_views.profile_detail(request, username, extra_context=context, *args, **kwargs)
def custom_profile_detail(request, username, *args, **kwargs): data = [] context_data = [] data += action_by_user(Accession, 'Accession', ['seq', 'title'], username, 'created') data += action_by_user(Accession, 'Accession', ['seq', 'title'], username, 'updated') data += action_by_user(Donor, 'Donor', ['name'], username, 'created') data += action_by_user(Donor, 'Donor', ['name'], username, 'updated') data += action_by_user(ArchivalUnit, 'Archival Unit', ['title_full'], username, 'created') data += action_by_user(ArchivalUnit, 'Archival Unit', ['title_full'], username, 'updated') data += action_by_user(Isaar, 'ISAAR-CPF', ['name'], username, 'created') data += action_by_user(Isaar, 'ISAAR-CPF', ['name'], username, 'updated') data += action_by_user(Isad, 'ISAD(G)', ['reference_code', 'title'], username, 'created') data += action_by_user(Isad, 'ISAD(G)', ['reference_code', 'title'], username, 'updated') data += action_by_user(Container, 'Container', ['get_reference_code'], username, 'created') data += action_by_user(Container, 'Container', ['get_reference_code'], username, 'updated') data += action_by_user( FindingAidsEntity, 'Finding Aids', ['archival_reference_code', 'title', 'template_name'], username, 'created') data += action_by_user( FindingAidsEntity, 'Finding Aids', ['archival_reference_code', 'title', 'template_name'], username, 'updated') data_array = sorted(data, key=itemgetter('date'), reverse=True)[:20] for k, v in groupby(data_array, key=lambda x: x['date']): context_data.append({'date': k, 'entries': list(v)}) return profile_detail(request, username=username, extra_context={'audit_log': context_data}, *args, **kwargs)
def my_profile_detail(request, username): black_list = ["signup", "",] if username in black_list: raise Http404 reservations = Reservation.objects.filter(user=request.user) assignments = Assignment.objects.filter(participants__username=request.user.username) booklists = BookList.objects.filter(user=request.user) transactions = Transaction.objects.filter(user=request.user) ratings = Vote.objects.filter(user=request.user) response = userena_views.profile_detail( request, username, extra_context={ 'reservations': reservations, 'assignments': assignments, 'booklists': booklists, 'transactions': transactions, 'ratings': ratings, } ) return response