Exemple #1
0
    def get_context_data(self, **kwargs):

        if self.referencia:
            self.template_name = 'path/path_imagem.html'
            context = TemplateView.get_context_data(self, **kwargs)
            context['object'] = self.referencia

        elif self.documento:
            context = self.get_context_data_documento(**kwargs)
        elif self.classe:
            context = self.get_context_data_classe(**kwargs)
        else:
            context = TemplateView.get_context_data(self, **kwargs)
        context['path'] = '-path'

        return context
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        try:
            related_project_list = []
            for related_project in Project.objects.exclude(id=kwargs.get('id')).order_by('?'):
                if not related_project.is_expired():
                    related_project_list.append(related_project)
            project = Project.objects.get(id=kwargs.get('id'))
            context['project'] = project
            # context['related_projects'] = Project.objects.exclude(id=kwargs.get('id').order_by('?'))[:3]
            context['related_projects'] = related_project_list[:3]
            context['pledges'] = Pledge.objects.filter(project=project).all()
            user = self.request.user
            if user.is_authenticated() and Pledge.objects.filter(project=project, user=user).exists():
                # starts here
                context['user_pledge'] = pledge = Pledge.objects.filter(project=project, user=user).first()
                if project.is_expired():
                    # Below code is used if campaign expired and achieved its goal, to help user fulfill pledge
                    payment_temp = PaymentTemp.objects.create(amount=pledge.amount, email_address=pledge.user.email,
                                flex_field="Fulfillment of pledge " + str(pledge.id),
                                referrer_url=self.request.get_full_path(), pledge_id=pledge.id)
                    form = PaymentTempForm(instance=payment_temp)
                    context['form'] = form
                    context['pt_id'] = payment_temp.id
                    # ends here
        except (Project.DoesNotExist, ValueError):
            raise Http404

        return context
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     members = {}
     for member in I4pProfile.objects.filter(motto__isnull=False).exclude(motto__exact='').order_by("?"):
         members[member.get_full_name_or_username] = member.motto.replace('"', '').capitalize()
     context["members"] = members
     return context
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     if self.mode == 'create':
         context['form'] = ProjectForm()
         context['mode'] = 'create'
     else:
         try:
             project_id = int(kwargs.get('id', ''))
             project = Project.objects.get(id=project_id)
             form = ProjectForm(instance=project)
             # logic for conditional editing
             # Google - How to make read only fields within Django form instance
             if project.is_expired():
                 form.fields['title'].widget.attrs['readonly'] = True
                 form.fields['summary'].widget.attrs['readonly'] = True
                 form.fields['goal'].widget.attrs['readonly'] = True
                 form.fields['period'].widget.attrs['readonly'] = True
                 form.fields['description'].widget.attrs['readonly'] = True
                 form.fields['team'].widget.attrs['readonly'] = True
                 form.fields['risks_and_challenges'].widget.attrs['readonly'] = True
             else:
                 form.fields['title'].widget.attrs['readonly'] = True
                 form.fields['summary'].widget.attrs['readonly'] = True
                 form.fields['goal'].widget.attrs['readonly'] = True
                 form.fields['period'].widget.attrs['readonly'] = True
             context['form'] = form
             context['mode'] = 'edit'
             context['id'] = project.id
             if project.author != self.request.user:
                 raise Http404
         except (Project.DoesNotExist, ValueError):
             raise Http404
     context['mode'] = self.mode
     return context
Exemple #5
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        context['title'] = 'Dashboard'
        context['title_icon'] = 'home'

        context['accounts'] = {
            'winbank': BankAccount.objects \
                .filter(institution__short_name='PIRBGRAA').count(),
            'nbg': BankAccount.objects \
                .filter(institution__short_name='ETHNGRAA').count(),
            'paypal': WalletAccount.objects \
                .filter(institution__short_name='PAYPAL').count(),
            'all': Account.objects.all(),
            'total': Account.objects.aggregate(Sum('balance'))
        }

        transactions = list(Transaction.objects.order_by('-posted').all())
        for trans in transactions:
            for account in context['accounts']['all']:
                if account.account_id == trans.this_account and \
                        account.account_type == trans.this_account_type:
                    trans.account = account
                    break
        context['transactions'] = transactions

        return context
Exemple #6
0
 def get_context_data(self, **kwargs):
     c = TemplateView.get_context_data(self, **kwargs)
     
     today = datetime.date.today()
     c['today'] = today # Added to the context so we can use it in the template
     
     # Query all tasks for the user, only parents, for this month
     c['tasks'] = Task.objects.filter(date__month=today.month,
                                      user=self.request.user,
                                      father__isnull=True)
     
     # Query all events for the user, for this month
     events = Event.objects.filter(date__month=today.month,
                                   user=self.request.user)
     
     # I need to put them under the correct day, so I create an ordered dict, using
     # the days of the month for as keys, and appending the events to the days
     # when the day of the event matches 
     c['events'] = OrderedDict()
     (_, last_day) = calendar.monthrange(today.year, today.month) # First argument discouraged
     
     # Initialize the OrderedDict
     for i in range(0, last_day):
         c['events'][datetime.date(today.year, today.month, i + 1)] = []
     
     # Fill the dict with events
     for event in events:
         c['events'][event.date].append(event)
     
     # returning the context
     return c
Exemple #7
0
    def get_context_data(self, **kwargs):
	context = TemplateView.get_context_data(self, **kwargs)
	
	context["data"] = get_all_data()
	context["authors"] = get_all_authors()

	return context
Exemple #8
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        assignment_id = self.kwargs['assignment_id']
        assignment = get_object_or_404(models.Assignment, identifier=assignment_id)
        question_id = self.kwargs['question_id']
        question = get_object_or_404(models.Question, id=question_id)

        # Limit number of rationales shown to a number between [0, AnswerAdmin.list_per_page]
        perpage = self.request.GET.get('perpage')
        try:
            perpage = int(perpage)
        except (TypeError, ValueError):
            perpage = None
        if (perpage is None) or (perpage <= 0) or (perpage > AnswerAdmin.list_per_page):
            perpage = AnswerAdmin.list_per_page

        sums, rationale_data = get_question_rationale_aggregates(assignment, question, perpage)
        context.update(
            assignment=assignment,
            question=question,
            summary_data=self.prepare_summary_data(sums),
            rationale_data=self.prepare_rationale_data(rationale_data),
            perpage=perpage,
        )
        return context
Exemple #9
0
 def get_context_data(self, **kwargs):
     data = TemplateView.get_context_data(self, **kwargs)
     data['model_token'] = settings.BIMSYNC_TOKEN
     if self.request.method == 'GET' and 'bim_only' in self.request.GET:
         data['bim_only'] = True
     else:
         data['bim_only'] = False
     return data
Exemple #10
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     form = AttributionAnalysisFilterForm(data=self.request.GET)
     if form.is_valid() and self.request.GET:
         context['username_data'], context['country_data'] = self.get_aggregates(
             form.cleaned_data.copy()
         )
     context.update(form=form)
     return context
Exemple #11
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     id = kwargs.get('id', '')
     try:
     	project = Project.objects.get(id=id)
     except Project.DoesNotExist:
     	raise Http404
     context['project'] = project
     return context
Exemple #12
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     try:
         project_id = int(kwargs.get('id', ''))
         project = Project.objects.get(id=project_id)
     except (Project.DoesNotExist, ValueError):
         raise Http404
     context['project'] = project
     return context
Exemple #13
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context["cubesviewer_cubes_url"] = settings.CUBESVIEWER_CUBES_URL
     context["cubesviewer_backend_url"] = settings.CUBESVIEWER_BACKEND_URL
     context["view_config"] = ''
     try:
         query = unquote(self.request.META['QUERY_STRING'])
         context["view_config"] = json_dumps(json_loads(query))
     except ValueError, e:
         pass
Exemple #14
0
    def get_context_data(self, **kwargs):
        kwargs['form'] = ReportForm()
        kwargs['payments_form'] = PaymentsReportForm()
        kwargs['actions'] = {
            'applications': reverse('wl_reports:applications_report'),
            'licences': reverse('wl_reports:licences_report'),
            'returns': reverse('wl_reports:returns_report'),
            'payments': reverse('wl_payments:payments_report'),
        }

        return TemplateView.get_context_data(self, **kwargs)
Exemple #15
0
 def get_context_data(self, **kwargs):
     _context = TemplateView.get_context_data(self, **kwargs)
     _date_str = self.kwargs.get('date')
     _current_date = parser.parse(_date_str)
     
     _result = Devotional.objects.filter(month = _current_date.month, day = _current_date.day)
     
     if len(_result) > 0:
         _context.setdefault('object', _result[0])
 
     return _context
Exemple #16
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        context['path'] = '-path'

        np = self.get_noticias_dos_parlamentares()

        context['noticias_dos_parlamentares'] = np

        context['noticias_da_procuradoria'] = self.get_noticias_da_procuradoria()

        return context
Exemple #17
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     postList = MyPost.objects.order_by("-cr_date")[:5]
     context["mypost_list"] = postList
     context["mypost_count"] = MyPost.objects.count()
     context["notice_list"] = Notice.objects.all()[:5]
     context["notice_count"] = Notice.objects.count()
     context["user_count"] = MyProfile.objects.count()
     context["faq_list"] = Question.objects.all()
     context["feed_list"] = Feedback.objects.all()
     context["feed_count"] = Feedback.objects.count()
     return context;
Exemple #18
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     self.assignment_id = self.kwargs['assignment_id']
     assignment = get_object_or_404(models.Assignment, identifier=self.assignment_id)
     sums, question_data = get_assignment_aggregates(assignment)
     switch_columns = sorted(k[1] for k in sums if isinstance(k, tuple) and k[0] == 'switches')
     context.update(
         assignment=assignment,
         assignment_data=self.prepare_assignment_data(sums, switch_columns),
         question_data=self.prepare_question_data(question_data, switch_columns),
     )
     return context
Exemple #19
0
    def get_context_data(self, **kwargs):
        _context = TemplateView.get_context_data(self, **kwargs)
        _date_str = self.kwargs.get('date')
        _current_date = parser.parse(_date_str)

        _result = Devotional.objects.filter(month=_current_date.month,
                                            day=_current_date.day)

        if len(_result) > 0:
            _context.setdefault('object', _result[0])

        return _context
Exemple #20
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context["boats_by_user"] = \
         BoatModel.objects.order_by("-boat_publish_date").\
     filter(author=self.request.user)[:10].only("boat_name", "id")
     context["articles_by_user"] = Article.objects.order_by("-created_at").filter(
         author=self.request.user)[: 10].only("title", "id")
     filter1 = Comment.objects.filter(foreignkey_to_article__author=self.request.user,
                 is_active=True).select_related('foreignkey_to_article', "foreignkey_to_boat")
     filter2 = Comment.objects.filter(foreignkey_to_boat__author=self.request.user,
                 is_active=True).select_related('foreignkey_to_article', "foreignkey_to_boat")
     context["comments_by_user"] = filter1.union(filter2).order_by("-created_at")[: 5]
     return context
Exemple #21
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     project = Project.objects.get(id=kwargs.get('id'))
     if project and self.request.user == project.author:
         context['form'] = ProjectForm(instance=project)
         context['mode'] = 'edit'
         context['id'] = project.id
     elif not project:
         context['form'] = ProjectForm()
         context['mode'] = 'create'
     else:
         raise Http404
     return context
Exemple #22
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     user = self.request.user
     if self.type == 'push':
         push = Push.objects.get(pk=self.pk_)
         context['push_feedback_taken'] = push.pushfeedback_set.exclude(
             status=0)
         context['push'] = push
     else:
         context['user_feedback_given'], context['user_feedback_taken'] = \
             self.get_feedback(user)
     context['user'] = user
     return context
Exemple #23
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context['form'] = ProjectUpdateForm()
     try:
         project_id = int(kwargs.get('id', ''))
         project = Project.objects.get(id=project_id)
         context['project'] = project
         # form = ProjectUpdateForm(instance=project)
         if project.author != self.request.user:
             raise Http404
     except (Project.DoesNotExist, ValueError):
         raise Http404
     # context['mode'] = self.mode
     return context
Exemple #24
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        context['path'] = '-path'

        np = self.get_noticias_dos_parlamentares()

        context['noticias_dos_parlamentares'] = np

        context[
            'noticias_da_procuradoria'] = self.get_noticias_da_procuradoria()

        context['ultimas_publicacoes'] = self.get_ultimas_publicacoes()

        return context
Exemple #25
0
 def get_context_data(self, **kwargs):
     def my_custom_sql(self):
         cursor = connection.cursor()
         cursor.execute("SELECT * FROM ( SELECT usuario.username, log.action_flag, log.object_repr, modelo.model, log.action_time FROM django_admin_log log INNER JOIN auth_user usuario ON log.user_id = usuario.id INNER JOIN django_content_type modelo ON log.content_type_id = modelo.id ORDER BY action_time DESC ) TEST;")
         #row = cursor.fetchone()
         desc = cursor.description
         return [
                 dict(zip([col[0] for col in desc], row))
                 for row in cursor.fetchall()
             ]
         
     context = TemplateView.get_context_data(self, **kwargs) 
     context['logs']= my_custom_sql(self)
     return context
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context['form'] = ProjectUpdateForm()
     try:
         project_id = int(kwargs.get('id', ''))
         project = Project.objects.get(id=project_id)
         context['project'] = project
         # form = ProjectUpdateForm(instance=project)
         if project.author != self.request.user:
             raise Http404
     except (Project.DoesNotExist, ValueError):
         raise Http404
     # context['mode'] = self.mode
     return context
Exemple #27
0
 def get_context_data(self, **kwargs):
     c = TemplateView.get_context_data(self, **kwargs)
     user_model = get_user_model()
     c['users'] = user_model.objects.all()
     if self.request.user.is_authenticated():
         c['notifications'] = Notification.objects.filter(
             user=self.request.user
         ).order_by(
             '-created'
         )
         c['settings_form'] = SettingsForm(
             instance=Settings.get_default_setting(self.request.user)
         )
         c['testmodel_form'] = forms.TestModelForm()
     return c
Exemple #28
0
 def get_context_data(self, **kwargs):
     c = TemplateView.get_context_data(self, **kwargs)
     user_model = get_user_model()
     c['users'] = user_model.objects.all()
     if self.request.user.is_authenticated():
         c['notifications'] = Notification.objects.filter(
             user=self.request.user
         ).order_by(
             '-created'
         )
         c['settings_form'] = SettingsForm(
             instance=Settings.get_default_setting(self.request.user)
         )
         c['testmodel_form'] = forms.TestModelForm()
     return c
Exemple #29
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     self.assignment_id = self.kwargs["assignment_id"]
     assignment = get_object_or_404(models.Assignment,
                                    identifier=self.assignment_id)
     sums, question_data = get_assignment_aggregates(assignment)
     switch_columns = sorted(k[1] for k in sums
                             if isinstance(k, tuple) and k[0] == "switches")
     context.update(
         assignment=assignment,
         assignment_data=self.prepare_assignment_data(sums, switch_columns),
         question_data=self.prepare_question_data(question_data,
                                                  switch_columns),
     )
     return context
Exemple #30
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     followedList = FollowUser.objects.filter(followed_by = self.request.user.myprofile)
     followedList2 = []
     for e in followedList:
         followedList2.append(e.profile)
     postList = MyPost.objects.filter(uploaded_by__in = followedList2).order_by("-id")
     
     for p1 in postList:
         p1.liked = False
         ob = PostLike.objects.filter(post = p1,liked_by=self.request.user.myprofile)
         if ob:
             p1.liked = True        
         obList = PostLike.objects.filter(post = p1)
         p1.likedno = obList.count()
     context["mypost_list"] = postList
     return context;
Exemple #31
0
 def get_context_data(self, **kwargs):
     if self.request.user.is_authenticated:
         create_action(self.request.user, 'DAILY_VISIT')
     context = TemplateView.get_context_data(self, **kwargs)
     user = self.request.user
     if user.is_authenticated:
         deals = []
         for deal in user.deals:
             deals.append(deal.set_pov(self.request.user))
         context['deals'] = deals
         context['user_feedback_open'] = user.userfeedback_set.filter(
             status=0)
         context['push_feedback_open'] = user.pushfeedback_set.filter(
             status=0)
         context['lobby'] = Chat.get_lobby()
         # context['chat'] = Chat.get_lobby()
     else:
         self.template_name = 'dashboard/dashboard_anonymous.html'
     return context
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        try:
            related_project_list = []
            for related_project in Project.objects.exclude(id=kwargs.get('id')).order_by('?'):
                if not related_project.is_expired():
                    related_project_list.append(related_project)
            project = Project.objects.get(id=kwargs.get('id'))
            context['project'] = project
            # context['related_projects'] = Project.objects.exclude(id=kwargs.get('id').order_by('?'))[:3]
            context['related_projects'] = related_project_list[:3]
            context['pledges'] = Pledge.objects.filter(project=project).all()
            user = self.request.user
            if user.is_authenticated() and Pledge.objects.filter(project=project, user=user).exists():
                context['user_pledge'] = Pledge.objects.filter(project=project, user=user).first()
        except (Project.DoesNotExist, ValueError):
            raise Http404

        return context
Exemple #33
0
 def get_context_data(self, **kwargs):
     c = TemplateView.get_context_data(self, **kwargs)
     
     today = datetime.date.today()
     c['today'] = today # Added to the context so we can use it in the template
     
     days = OrderedDict()
     c['days'] = days
     
     q = Q(date=today) & Q(user=self.request.user)
     tasks = Task.objects.filter(q).filter(father__isnull=True).all()
     events = Event.objects.filter(q).all()
     notes = Note.objects.filter(q).all()
     
     days[today] = chain(tasks, events, notes) 
     
     print c['days']
     
     return c
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self,**kwargs)
     followedlist = FollowUser.objects.filter(followed_by = self.request.user.myprofile)
     followedlist2 = []
     for e in followedlist:
         followedlist2.append(e.profile)
     si = self.request.GET.get('si')
     if si == None:
         si = ""
     postList = MyPost.objects.filter(Q(uploaded_by__in = followedlist2)).filter(Q(subject__icontains = si))
     for p1 in postList:
         p1.liked = False
         ob = PostLike.objects.filter(post = p1,liked_by = self.request.user.myprofile)
         if ob:
             p1.liked = True
     ob = PostLike.objects.filter(post = p1)
     p1.likecount = ob.count()
     context["mypost_list"] = postList 
     return context
Exemple #35
0
    def get_context_data(self, **kwargs):
        c = TemplateView.get_context_data(self, **kwargs)

        today = datetime.date.today()
        c['today'] = today  # Added to the context so we can use it in the template

        days = OrderedDict()
        c['days'] = days

        q = Q(date=today) & Q(user=self.request.user)
        tasks = Task.objects.filter(q).filter(father__isnull=True).all()
        events = Event.objects.filter(q).all()
        notes = Note.objects.filter(q).all()

        days[today] = chain(tasks, events, notes)

        print c['days']

        return c
Exemple #36
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        profile_id = self.kwargs['profile_id']

        if not profile_id:
            return context

        try:
            if is_integer(profile_id):
                user_profile = UserProfile.objects.get(id=profile_id)
            else:
                user_profile = UserProfile.objects.get(slug=profile_id)
            context['user_profile'] = user_profile
        except UserProfile.DoesNotExist:
            return context

        student_sections = StudentSection.objects.filter(userprofile=user_profile)
        if student_sections:
            student_section = student_sections[0]
            context['student_section'] = student_section
            context['all_student_sections'] = student_sections

            if student_section.branch:
                related_profiles = StudentSection.objects.filter(
                    branch=student_section.branch,
                    year_of_graduation=student_section.year_of_graduation).exclude(
                    id=student_section.id)[
                    :5]
            else:
                related_profiles = StudentSection.objects.filter(
                        year_of_graduation=student_section.year_of_graduation).exclude(
                        id=student_section.id)[
                        :5]

            context['other_profiles'] = related_profiles

        context['education_details'] = HigherEducationDetail.objects.filter(userprofile=user_profile)
        context['employment_details'] = EmploymentDetail.objects.filter(userprofile=user_profile)
        context['faculty_details'] = FacultySection.objects.filter(userprofile = user_profile)
        context['tags'] = user_profile.tags.all()

        return context
Exemple #37
0
    def get_context_data(self, **kwargs):
        ctx = TemplateView.get_context_data(self, **kwargs)

        ingredients = [
            int(x) for x in self.request.GET.get('ingredients', '').split(',')
        ] if self.request.GET.get('ingredients', None) else None
        categories = self.request.GET.getlist('categories', [])
        recipes_basic_fiter =  Recipe.objects.annotate(total_ing_num=Count("ingredients__ingredient_id"),
                                                       searched_ing_num=Count(Case(
                                                                        When(ingredients__ingredient_id__in=ingredients, then=1)))).\
                                            filter(searched_ing_num__lte=len(ingredients), searched_ing_num__gt=0)
        all_ingredient_recipes = recipes_basic_fiter.filter(
            total_ing_num=F("searched_ing_num"))
        one_missing_recipes = recipes_basic_fiter.filter(
            total_ing_num=(F("searched_ing_num") + 1))
        two_missing_recipes = recipes_basic_fiter.filter(
            total_ing_num=(F("searched_ing_num") + 2))
        more_than_two_missing_recipes = recipes_basic_fiter.filter(
            total_ing_num__gt=(F("searched_ing_num") + 2))

        if categories:
            all_ingredient_recipes = all_ingredient_recipes.filter(
                categories__category_id__in=[int(x) for x in categories])
            one_missing_recipes = one_missing_recipes.filter(
                categories__category_id__in=[int(x) for x in categories])
            two_missing_recipes = two_missing_recipes.filter(
                categories__category_id__in=[int(x) for x in categories])
            more_than_two_missing_recipes = more_than_two_missing_recipes.filter(
                categories__category_id__in=[int(x) for x in categories])

        ctx.update({
            "all_ingredients":
            [self.get_recipe_json(x) for x in all_ingredient_recipes],
            "one_missing":
            [self.get_recipe_json(x) for x in one_missing_recipes],
            "two_missing":
            [self.get_recipe_json(x) for x in two_missing_recipes],
            "more_than_two_missing":
            [self.get_recipe_json(x) for x in more_than_two_missing_recipes],
        })

        return ctx
Exemple #38
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     # pk всех существующих  в базе лодок
     existing_boats_pk = BoatModel.objects.all().values_list("pk", flat=True).iterator()
     #  Выбираем все удаленные лодки текущим пользователем
     if self.request.user.is_superuser:
         #  показываем лодки без автора для суперюзера
         q = Q(revision__user_id=self.request.user.id) | Q(revision__user_id__isnull=True)
     else:
         q = Q(revision__user_id=self.request.user.id)
     versions = Version.objects.get_for_model(BoatModel).filter(
         q).exclude(object_id__in=existing_boats_pk).order_by("object_id").distinct(
         "object_id")
     context["versions"] = versions
     context["id_eq"] = [version.id for version in versions]
     #  ограничиваем кол-во выдаваемых фоток 3-мя штуками
     memory_limiter = set(BoatImage.objects.filter(boat_id__isnull=True).exclude(
         memory__in=existing_boats_pk).values_list("memory", "pk"))
     cnt = []
     superfluous_images = set()
     for memory in memory_limiter:
         cnt.append(memory[0])
         if cnt.count(memory[0]) > 3:
             superfluous_images.add(memory)
     # фото всех удаленных лодок
     images = BoatImage.objects.filter(boat_id__isnull=True, pk__in=[pk for memory, pk in
                 (memory_limiter - superfluous_images)]).exclude(
         memory__in=existing_boats_pk)
     # список рк всех фоток не привязанных к лодкам
     images.memory_list = str(images.values_list("memory", flat=True))
     for image in images:
         image.memory = str(image.memory)
     context["images"] = images
     #  передаем имена лодок в следующий контроллер ReversionDeleteView
     version_objects = {version.object_id: version.field_dict.get("boat_name")
                        for version in versions}
     self.request.session["versions"] = version_objects
     return context
Exemple #39
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        try:
            related_project_list = []
            for related_project in Project.objects.exclude(
                    id=kwargs.get('id')).order_by('?'):
                if not related_project.is_expired():
                    related_project_list.append(related_project)
            project = Project.objects.get(id=kwargs.get('id'))
            context['project'] = project
            # context['related_projects'] = Project.objects.exclude(id=kwargs.get('id').order_by('?'))[:3]
            context['related_projects'] = related_project_list[:3]
            context['pledges'] = Pledge.objects.filter(
                project=project).all().order_by('-pledge_fulfilled')
            context['total_pledge_fulfilled'] = Pledge.objects.filter(
                project=project, pledge_fulfilled=True).count()
            user = self.request.user
            if user.is_authenticated() and Pledge.objects.filter(
                    project=project, user=user).exists():
                # starts here
                context['user_pledge'] = pledge = Pledge.objects.filter(
                    project=project, user=user).first()
                if project.is_expired():
                    # Below code is used if campaign expired and achieved its goal, to help user fulfill pledge
                    payment_temp = PaymentTemp.objects.create(
                        amount=pledge.amount,
                        email_address=pledge.user.email,
                        flex_field="Fulfillment of pledge " + str(pledge.id),
                        referrer_url=self.request.get_full_path(),
                        pledge_id=pledge.id)
                    form = PaymentTempForm(instance=payment_temp)
                    context['form'] = form
                    context['pt_id'] = payment_temp.id
                    # ends here
        except (Project.DoesNotExist, ValueError):
            raise Http404

        return context
Exemple #40
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs) 
        musica_id = ''
        if 'nomemusica' in kwargs and kwargs['nomemusica']:
            musica_id = Musica.objects.filter(id=kwargs['nomemusica'])
        print('teste -------------->', musica_id)
        def my_custom_sql(self):
                
            cursor = connection.cursor()
            cursor.execute("select c.date, m.name from gospelsongsdb_culto_musicas cm \
            inner join gospelsongsdb_culto c on c.id = cm.culto_id \
            inner join gospelsongsdb_musica m on m.id = cm.musica_id \
            where m.id = %s;",[musica_id])
            #row = cursor.fetchone()
            desc = cursor.description

            return [
                    dict(zip([col[0] for col in desc], row))
                    for row in cursor.fetchall()
                ]
        context['mais_tocadas']= my_custom_sql(self)
        context['musicas'] = Musica.objects.all()
        return context
Exemple #41
0
    def get_context_data(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)
        si = self.request.GET.get("si")
        if si == None:
            si = ""

        postlist = Post.objects.filter(
            Q(uploaded_by=self.request.user.profile)).filter(
                Q(subject__icontains=si)
                | Q(msg__icontains=si)).order_by("-id")

        for p in postlist:
            p.liked = False
            ob = PostLike.objects.filter(post=p,
                                         liked_by=self.request.user.profile)
            if ob:
                p.liked = True
            ob = PostLike.objects.filter(post=p)
            comment_count = Comment.objects.filter(post=p)
            p.comment_count = comment_count.count
            p.likes = ob.count

        context["post_list"] = postlist
        return context
Exemple #42
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context["feed_obj"] = Feedback.objects.all()
     context["feed_count"] = Feedback.objects.count()
     return context;
Exemple #43
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context['lobby'] = Chat.get_lobby()
     return context
Exemple #44
0
 def get_context_data(self, **kwargs):
     c = TemplateView.get_context_data(self, **kwargs)
     c['report_types'] = (('PDF', 'PDF'), ('HTML', 'HTML'))
     c['TEST_CASE_TYPES'] = TestCase.TEST_CASE_TYPES
     c['EXECUTION_TYPES'] = TestCase.EXECUTION_TYPES
     return c
Exemple #45
0
    def get_context_data(self, **kwargs):

        if self.parlamentar.template_classe != \
                CLASSE_TEMPLATES_CHOICE.parlamentares:
            context = PathView.get_context_data(self, **kwargs)

        else:
            context = TemplateView.get_context_data(self, **kwargs)
            context['object'] = self.classe

            legislatura_ativa = int(self.request.GET.get('l', '0'))
            sl_ativa = int(self.request.GET.get('sl', '0'))
            #parlamentar_ativo = int(self.request.GET.get('p', '0'))

            legs = Legislatura.objects
            pms = Parlamentar.objects

            # if parlamentar_ativo:
            #    context['parlamentar_ativo'] = pms.get(pk=parlamentar_ativo)

            legislaturas = []
            context['legislatura_ativa'] = 0
            context['sessaolegislativa_ativa'] = 0
            for l in legs.all():

                # if l.numero < 17:
                #    continue

                if not legislatura_ativa and l.atual() or \
                        l.pk == legislatura_ativa:
                    context['legislatura_ativa'] = l

                leg = {'legislatura': l, 'sessoes': [], 'parlamentares': []}

                fs = l.sessaolegislativa_set.first()
                for s in l.sessaolegislativa_set.all():

                    if s.pk == sl_ativa or not sl_ativa and s == fs and \
                            s.legislatura == context['legislatura_ativa']:
                        context['sessaolegislativa_ativa'] = s
                        if s.pk == sl_ativa:
                            context['legislatura_ativa'] = l

                    # if s.legislatura != context['legislatura_ativa']:
                    #    continue

                    sessao = {
                        'sessao': s,
                    }

                    if s == context['sessaolegislativa_ativa']:
                        sessao.update({
                            'mesa': [
                                p for p in pms.filter(
                                    mandato__legislatura=l,
                                    composicaomesa__sessao_legislativa=s).
                                annotate(cargo_mesa=F(
                                    'composicaomesa__cargo__descricao')).
                                order_by('composicaomesa__cargo__descricao')
                            ],
                            'parlamentares': [
                                p for p in pms.filter(
                                    mandato__legislatura=l).exclude(
                                        composicaomesa__sessao_legislativa=s).
                                annotate(
                                    afastado=F('mandato__tipo_afastamento'),
                                    titular=F('mandato__titular')).order_by(
                                        '-ativo', '-mandato__titular',
                                        'nome_parlamentar')
                            ]
                        })

                    leg['sessoes'].append(sessao)

                if not leg['sessoes'] and l == context['legislatura_ativa']:
                    for p in pms.filter(mandato__legislatura=l):
                        leg['parlamentares'].append(p)

                legislaturas.append(leg)

            context['legislaturas'] = legislaturas

        return context
Exemple #46
0
 def get_context_data(self, **kwargs):
     ctx = TemplateView.get_context_data(self, **kwargs)
     endpoint = getattr(settings, 'ASSET_CONVERT_API', None)
     ctx['endpoint'] = endpoint is not None
     ctx['assets'] = Asset.objects.filter(course=self.request.course)
     return ctx
Exemple #47
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context['collection'] = self.get_collection()
     return context
Exemple #48
0
    def get_context_data(self, **kwargs):

        if self.parlamentar.template_classe != \
                CLASSE_TEMPLATES_CHOICE.parlamentares:
            context = PathView.get_context_data(self, **kwargs)

        else:
            context = TemplateView.get_context_data(self, **kwargs)
            context['object'] = self.classe

            legislatura_ativa = int(self.request.GET.get('l', '0'))
            sl_ativa = int(self.request.GET.get('sl', '0'))
            #parlamentar_ativo = int(self.request.GET.get('p', '0'))

            legs = Legislatura.objects
            pms = Parlamentar.objects

            # if parlamentar_ativo:
            #    context['parlamentar_ativo'] = pms.get(pk=parlamentar_ativo)

            legislaturas = []
            context['legislatura_ativa'] = 0
            context['sessaolegislativa_ativa'] = 0
            for l in legs.all():

                # if l.numero < 17:
                #    continue
                l_atual = l.atual()

                if not legislatura_ativa and l.atual() or \
                        l.pk == legislatura_ativa:
                    context['legislatura_ativa'] = l

                leg = {'legislatura': l, 'sessoes': [], 'parlamentares': []}

                fs = l.sessaolegislativa_set.first()
                for s in l.sessaolegislativa_set.all():

                    if s.pk == sl_ativa or not sl_ativa and s == fs and \
                            s.legislatura == context['legislatura_ativa']:
                        context['sessaolegislativa_ativa'] = s
                        if s.pk == sl_ativa:
                            context['legislatura_ativa'] = l

                    # if s.legislatura != context['legislatura_ativa']:
                    #    continue

                    sessao = {
                        'sessao': s,
                    }

                    if s == context['sessaolegislativa_ativa']:
                        sessao.update({
                            'mesa': [
                                p for p in pms.filter(
                                    mandato__legislatura=l,
                                    composicaomesa__sessao_legislativa=s).
                                annotate(cargo_mesa=F(
                                    'composicaomesa__cargo__descricao')).
                                order_by('composicaomesa__cargo__descricao')
                            ],
                            'parlamentares': [
                                p for p in pms.filter(
                                    mandato__legislatura=l).exclude(
                                        composicaomesa__sessao_legislativa=s).
                                order_by(
                                    '-ativo', '-mandato__data_fim_mandato',
                                    '-mandato__titular', 'nome_parlamentar').
                                annotate(data_inicio_mandato=F(
                                    'mandato__data_inicio_mandato'),
                                         data_fim_mandato=F(
                                             'mandato__data_fim_mandato'),
                                         afastado=F('afastamentoparlamentar'),
                                         titular=F(
                                             'mandato__titular')).distinct()
                            ]
                        })

                    if 'parlamentares' in sessao:
                        n = timezone.now()
                        sessao['parlamentares'] = sorted(
                            list(set(sessao['parlamentares'])),
                            key=lambda x: x.nome_parlamentar)

                        for p in sessao['parlamentares']:
                            if not l_atual:
                                p.afastado = False
                                continue

                            if not p.data_inicio_mandato <= n.date(
                            ) <= p.data_fim_mandato:
                                p.afastado = True
                                continue

                            if not p.afastado:
                                continue

                            af = p.afastamentoparlamentar_set.filter(
                                data_inicio__lte=n, data_fim__gte=n).exists()

                            if not af:
                                p.afastado = None

                    leg['sessoes'].append(sessao)

                if not leg['sessoes'] and l == context['legislatura_ativa']:
                    for p in pms.filter(mandato__legislatura=l):
                        leg['parlamentares'].append(p)

                legislaturas.append(leg)

            context['legislaturas'] = legislaturas

        return context
Exemple #49
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     category = get_category_by_slug(self.kwargs['category_slug'])
     context['projects'] = Project.site_objects.active().filter(category=category).order_by('order')
     context['category'] = category
     return context
Exemple #50
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
 	projects = Project.objects.all()
     context['projects'] = projects
     return context
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context['projects'] = Project.objects.all()
     return context
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context["cubesviewer_cubes_url"] = settings.CUBESVIEWER_CUBES_URL
     context["cubesviewer_backend_url"] = settings.CUBESVIEWER_BACKEND_URL
     return context
 def get_context_data(self, **kwargs):
     ctx = TemplateView.get_context_data(self, **kwargs)
     ctx.update({
         'error': self.error_message
     })
     return ctx
Exemple #54
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context.update(assignments=models.Assignment.objects.all())
     return context
Exemple #55
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     # project = Project.objects.get(id=kwargs.get('id'))
     context['projects'] = Project.objects.all()
     return context
Exemple #56
0
 def get_context_data(self, **kwargs):
     #context = super(HelloTemplateView, self).get_context_data(**kwargs)
     context = TemplateView.get_context_data(self, **kwargs)
     context['name'] = "murphyki"
     return context
Exemple #57
0
    def get_context_data_documento(self, **kwargs):
        context = TemplateView.get_context_data(self, **kwargs)

        if self.documento.tipo == Documento.TPD_GALLERY:
            self.template_name = 'path/path_gallery.html'

        elif self.documento.tipo == Documento.TPD_IMAGE:
            self.template_name = 'path/path_imagem.html'
            context['object'] = self.documento
            context['referencia'] = None
        else:
            parlamentares = self.documento.parlamentares.all()

            if hasattr(self, 'parlamentar') and self.parlamentar:
                parlamentares = parlamentares.filter(
                    pk=self.parlamentar.parlamentar.pk)

            if self.documento.public_date:

                if parlamentares:

                    next = Documento.objects.qs_news().filter(
                        public_date__gte=self.documento.public_date,
                        classe=self.documento.classe,
                        parlamentares__in=parlamentares,
                    ).exclude(id=self.documento.id).last()

                    previous = Documento.objects.qs_news().filter(
                        public_date__lte=self.documento.public_date,
                        classe=self.documento.classe,
                        parlamentares__in=parlamentares,
                    ).exclude(id=self.documento.id).first()
                else:

                    next = Documento.objects.qs_news().filter(
                        public_date__gte=self.documento.public_date,
                        classe=self.documento.classe,
                        parlamentares__isnull=True,
                    ).exclude(id=self.documento.id).last()

                    previous = Documento.objects.qs_news().filter(
                        public_date__lte=self.documento.public_date,
                        classe=self.documento.classe,
                        parlamentares__isnull=True,
                    ).exclude(id=self.documento.id).first()

            else:
                next = None
                previous = None

            context['next'] = next
            context['previous'] = previous

            docs = Documento.objects.qs_news().exclude(id=self.documento.id)

            if parlamentares.exists():
                docs = docs.filter(parlamentares__in=parlamentares)
            else:
                docs = docs.filter(parlamentares__isnull=True)

            if parlamentares.count() > 4:
                docs = docs.distinct('parlamentares__id').order_by(
                    'parlamentares__id')

            context['object_list'] = docs[:4]

        context['object'] = self.documento
        return context
Exemple #58
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context["notices"] = Notice.objects.all().order_by('-id')[:3];
     context["questions"] = Question.objects.all().order_by('-id')[:3];
     return context;
Exemple #59
0
 def get_context_data(self, **kwargs):
     contex_data = TemplateView.get_context_data(self, **kwargs)
     process = get_object_or_404(Process, pk=self.kwargs['process_id'], owner=self.request.user)
     contex_data['process'] = process;
     return contex_data
Exemple #60
0
 def get_context_data(self, **kwargs):
     context = TemplateView.get_context_data(self, **kwargs)
     context["notices"] = Notice.objects.order_by("-id")[:3]
     context["questions"] = Question.objects.order_by("-id")[:3]
     return context;