Commits

Artur Barseghyan  committed 5f4ee83 Draft

fix sample app + adding jquery cdn

  • Participants
  • Parent commits 4e232fd

Comments (0)

Files changed (2)

File example/example/foo/reports.py

 
 from foo.models import FooItem
 
+get_user_info = lambda u: "%s <%s>" % ((u.get_full_name() if u.get_full_name() else u.username), u.email)
+get_users_info = lambda uu: ','.join([get_user_info(u) for u in uu])
+
 # Define the report class
 class FooReport(sirep.Report):
-    verbose_name = 'Test report'
+    verbose_name = 'Foo item report'
     fields = [u'ID', u'Title', u'Editor', u'Authors', u'Main category', u'Categories', u'Date published',
               u'Character count body']
     items = []
     queryset = FooItem._default_manager.filter().select_related('editor', 'category') \
                       .prefetch_related('categories', 'authors')
 
-    get_user_info = lambda u: "%s <%s>" % ((u.get_full_name() if u.get_full_name() else u.username), u.email)
-    get_users_info = lambda uu: ','.join([get_user_info(u) for u in uu])
-    
-
     def process_data(self):
         queryset = self.get_queryset()
 
             self.items.append([
                 a.pk,
                 a.title,
-                self.get_user_info(self.editor),
-                self.get_users_info(self.authors),
-                self.category,
-                ', '.join([c.name for c in self.categories]),
-                self.date_published,
-                len(strip_tags(self.body)),
+                get_user_info(a.editor),
+                get_users_info(a.authors.all()),
+                a.category.name,
+                ', '.join([c.name for c in a.categories.all()]),
+                a.date_published,
+                len(strip_tags(a.body)),
                 ])
 
 # Register the report

File src/sirep/templates/sirep/view.html

 {% endblock %}
 
 {% block extrahead %}
+<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
 <script>function gettext(txt){ return txt}</script>
 <script>
-    jQuery(document).ready(function() {
-        jQuery('#generate-csv-report, #generate-csv-report-current-page').click(function() {
-            jQuery('.report-loading').height(jQuery(window).height());
-            jQuery('.report-loading').show();
+    $(document).ready(function() {
+        $('#generate-csv-report, #generate-csv-report-current-page').click(function() {
+            $('.report-loading').height($(window).height());
+            $('.report-loading').show();
         });
 
-        jQuery('.report-loading').click(function() {
-            jQuery('.report-loading').hide();
+        $('.report-loading').click(function() {
+            $('.report-loading').hide();
         });
 
-        jQuery('#apply-filtering-to-current-page').click(function() {
-            window.location = "{{ request.path }}?" + jQuery('.report-form').serialize();
+        $('#apply-filtering-to-current-page').click(function() {
+            window.location = "{{ request.path }}?" + $('.report-form').serialize();
             return;
         });
     });