Exemple #1
0
            url(r'^examples/$',
                self.decorate(TemplateView.as_view(template_name='advreport_examples/examples.html')),
                name='examples'),
        )

    def page(self, request):
        return TemplateResponse(request, 'advanced_reports/backoffice/tests/page.html', {'backoffice': self})


todos_backoffice = TodosBackoffice(name='todos')


todos_backoffice.register_model(UserModel)
todos_backoffice.register_view(UserView)
todos_backoffice.register_view(SimpleView)

todos_backoffice.register_model(TodoListModel)
todos_backoffice.register_model(TodoItemModel)
todos_backoffice.register_view(TodoListsView)

todos_backoffice.register_view(AdvancedReportView)
todos_backoffice.register_view(AdvancedReportActionView)

todos_backoffice.register_view(ExampleIncludeTemplateView)
todos_backoffice.register_view(ExampleIncludePythonView)

advanced_reports.register(NoModelReport)
advanced_reports.register(UserReport)
advanced_reports.register(NewStyleReport)
advanced_reports.register(TodoListReport)
        form.save()

    @action(verbose_name='Remove', confirm='Are you sure?')
    def remove(self, item):
        item.delete()

    @action(verbose_name='Dialog')
    def dialog(self, item):
        return 'Hello I am a dialog for %s!' % item.first_name

    def verify_action_group(self, item, group):
        if group is None: return True
        return False


advanced_reports.register(SimpleReport)


class ReportViewsTestCase(TestCase):
    @classmethod
    def setUpClass(cls):
        User.objects.all().delete()
        cls.u = User.objects.create(username='******', password='******', email='*****@*****.**',
                                    first_name='Test', last_name='User')
        cls.user_checkbox = 'checkbox_0000_%d' % cls.u.pk

    def setUp(self):
        self.client = client.Client()

    def test_list(self):
        response = self.client.get('/reports/simple/')
Exemple #3
0
    def get(self, request):
        user = get_object_or_404(User, pk=request.view_params.get('pk'))
        form = UserForm(instance=user)
        return self.render(request, user, form)

    def post(self, request):
        user = get_object_or_404(User, pk=request.view_params.get('pk'))
        form = UserForm(request.POST, instance=user)
        if form.is_valid():
            form.save()
            messages.success(request, u'Successfully saved user details! Try a search now...')
        return self.render(request, user, form)

    def update(self, request):
        data = request.view_params.get('data')
        user = get_object_or_404(User, pk=request.view_params.get('pk'))
        user.first_name = data['first_name']
        user.last_name = data['last_name']
        user.save()
        return data


test_backoffice = TestBackOffice()
test_backoffice.register_model(UserModel)
test_backoffice.register_view(AdvancedReportView)
test_backoffice.register_view(UserView)
test_backoffice.register_view(SimpleView)

advanced_reports.register(UserReport)
Exemple #4
0
        user = get_object_or_404(User, pk=request.view_params.get('pk'))
        form = UserForm(instance=user)
        return self.render(request, user, form)

    def post(self, request):
        user = get_object_or_404(User, pk=request.view_params.get('pk'))
        form = UserForm(request.POST, instance=user)
        if form.is_valid():
            form.save()
            messages.success(
                request,
                u'Successfully saved user details! Try a search now...')
        return self.render(request, user, form)

    def update(self, request):
        data = request.view_params.get('data')
        user = get_object_or_404(User, pk=request.view_params.get('pk'))
        user.first_name = data['first_name']
        user.last_name = data['last_name']
        user.save()
        return data


test_backoffice = TestBackOffice()
test_backoffice.register_model(UserModel)
test_backoffice.register_view(AdvancedReportView)
test_backoffice.register_view(UserView)
test_backoffice.register_view(SimpleView)

advanced_reports.register(UserReport)