예제 #1
0
    def rows(self):
        link = reverse('input_stock',
                       args=[self.domain, self.location.site_code])
        rows = []

        if has_input_stock_permissions(
                self.config['user'],
                SQLLocation.objects.get(
                    location_id=self.config['location_id']), self.domain):
            rows.append([
                u"<a href='{}'>INPUT STOCK for {}</a>".format(
                    link, self.location.name)
            ])

        try:
            rows.append([
                u'The last report received was at <b>{}.</b>'.format(
                    StockState.objects.filter(
                        case_id=self.location.supply_point_id).values(
                            'last_modified_date').latest('last_modified_date')
                    ['last_modified_date'].strftime("%X on %b %d, %Y"))
            ])
        except StockState.DoesNotExist:
            pass
        return rows
예제 #2
0
    def rows(self):
        link = reverse('input_stock',
                       args=[self.domain, self.location.site_code])
        transactions = StockTransaction.objects.filter(
            case_id=self.location.supply_point_id,
            report__date__lte=self.config['enddate']).order_by(
                '-report__date', 'pk')
        rows = []

        if has_input_stock_permissions(
                self.config['user'],
                SQLLocation.objects.get(
                    location_id=self.config['location_id']), self.domain):
            rows.append([
                u"<a href='{}'>INPUT STOCK for {}</a>".format(
                    link, self.location.name)
            ])

        if transactions:
            rows.append([
                u'The last report received was at <b>{}.</b>'.format(
                    transactions[0].report.date.strftime("%X on %b %d, %Y"))
            ])

        return rows
예제 #3
0
    def dispatch(self, request, *args, **kwargs):
        couch_user = self.request.couch_user
        site_code = kwargs['site_code']
        try:
            sql_location = SQLLocation.objects.get(site_code=site_code, domain=self.domain)
            if not has_input_stock_permissions(couch_user, sql_location, self.domain):
                raise PermissionDenied()
        except SQLLocation.DoesNotExist:
            raise Http404()

        return super(InputStockView, self).dispatch(request, *args, **kwargs)
예제 #4
0
    def dispatch(self, request, *args, **kwargs):
        couch_user = self.request.couch_user
        site_code = kwargs['site_code']
        try:
            sql_location = SQLLocation.objects.get(site_code=site_code, domain=self.domain)
            if not has_input_stock_permissions(couch_user, sql_location, self.domain):
                raise PermissionDenied()
        except SQLLocation.DoesNotExist:
            raise Http404()

        return super(InputStockView, self).dispatch(request, *args, **kwargs)
예제 #5
0
    def rows(self):
        link = reverse('input_stock', args=[self.domain, self.location.site_code])
        transactions = StockTransaction.objects.filter(
            case_id=self.location.supply_point_id,
            report__date__lte=self.config['enddate']
        ).order_by('-report__date', 'pk')
        rows = []

        if has_input_stock_permissions(self.config['user'],
                                       SQLLocation.objects.get(location_id=self.config['location_id']),
                                       self.domain):
            rows.append([u"<a href='{}'>INPUT STOCK for {}</a>".format(link, self.location.name)])

        if transactions:
            rows.append(
                [
                    u'The last report received was at <b>{}.</b>'.format(
                        transactions[0].report.date.strftime("%X on %b %d, %Y")
                    )
                ]
            )

        return rows
예제 #6
0
    def rows(self):
        link = reverse('input_stock', args=[self.domain, self.location.site_code])
        rows = []

        if has_input_stock_permissions(self.config['user'],
                                       SQLLocation.objects.get(location_id=self.config['location_id']),
                                       self.domain):
            rows.append(["<a href='{}'>INPUT STOCK for {}</a>".format(link, self.location.name)])

        try:
            rows.append(
                [
                    'The last report received was at <b>{}.</b>'.format(
                        StockState.objects.filter(case_id=self.location.supply_point_id)
                        .values('last_modified_date')
                        .latest('last_modified_date')['last_modified_date']
                        .strftime("%X on %b %d, %Y")
                    )
                ]
            )
        except StockState.DoesNotExist:
            pass
        return rows