Coverage for django_image_tools/__init__ : 24 | 100% 25 |
26 |
27 |
27 |
39 | Hot-keys on this page
40 |42 | r 43 | m 44 | x 45 | p toggle line displays 46 |
47 |48 | j 49 | k next/prev highlighted chunk 50 |
51 |52 | 0 (zero) top of page 53 |
54 |55 | 1 (one) first highlighted chunk 56 |
57 || 64 | 65 | | 66 |67 | 68 | | 69 |
27 |
39 | Hot-keys on this page
40 |42 | r 43 | m 44 | x 45 | p toggle line displays 46 |
47 |48 | j 49 | k next/prev highlighted chunk 50 |
51 |52 | 0 (zero) top of page 53 |
54 |55 | 1 (one) first highlighted chunk 56 |
57 || 64 | 65 | 66 | | 67 |68 | 69 | 70 | | 71 |
56 | Please activate JavaScript to enable the search 57 | functionality. 58 |
59 |61 | From here you can search these documents. Enter your search 62 | words into the box below and click "search". Note that the search 63 | function will automatically search for all of the words. Pages 64 | containing fewer words won't appear in the result list. 65 |
66 | 71 | 72 |The app only creates the image the first time it is requested. So don’t worry about the system clogging 55 | because you have 10.0000 images and you create a new size on the fly, or having your server filled up with cached 56 | images that are never used. 57 | The images are also cached, so you should never experience a notable lag, unless you request a bunch of images 58 | of a size that was never processed. 59 | The app uses an md5 checksum to check if the image was changed. This way, it can detect even if the image was 60 | replaced by some other app, (or the user) and reprocess the various sizes of that image on request.
61 |The images will all be available in the admin panel. You can browse and search through all of them. 55 | Sometimes, the users will upload a ‘small’ image (You know users right?) and then they’ll complain that the image 56 | doesn’t scale well, or it’s too jpegged. 57 | The app will automatically flag all images for which an upscaled version was requested, by flagging them with the 58 | ‘was_upscaled’ flag (if you’re using django_suit, the background of the row will also be displayed red). You can use the filter in the app to see which one were upscaled, and delete them, or replace them with a higher-res version. 59 | The original images will never be touched, unless the user wants to rename them. 60 | The cached image folder can be changed in the system settings, through the settings variable 61 | ‘DJANGO_IMAGE_TOOLS_CACHE_DIR’. This will always be a sub dir of the ‘MEDIA’ dir, though I might change this 62 | in the future. 63 | I strongly advice you to use the ‘raw_id_fields’ for the image fields, as it will allow the user to search for a 64 | previously submitted image or input a new one with a nice popup menu. This will decrease the number of duplicates. 65 | I also strongly advice you to remove permission for non admin users for the ‘size’ app, as removing a size that is 66 | used inside a template will result (obviously) in a 500 error. 67 | If there is a ‘thumbnail’ size, the app will display images of that size for the admin panel, otherwise it will fall 68 | back on the original. 69 | You can fetch the original image path by requesting ‘image.get__original’.
70 |
52 |
53 |
54 |
55 | Contents:
57 |' + _('Hide Search Matches') + '
') 181 | .appendTo($('#searchbox')); 182 | } 183 | }, 184 | 185 | /** 186 | * init the domain index toggle buttons 187 | */ 188 | initIndexTable : function() { 189 | var togglers = $('img.toggler').click(function() { 190 | var src = $(this).attr('src'); 191 | var idnum = $(this).attr('id').substr(7); 192 | $('tr.cg-' + idnum).toggle(); 193 | if (src.substr(-9) == 'minus.png') 194 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 195 | else 196 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 197 | }).css('display', ''); 198 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 199 | togglers.click(); 200 | } 201 | }, 202 | 203 | /** 204 | * helper function to hide the search marks again 205 | */ 206 | hideSearchWords : function() { 207 | $('#searchbox .highlight-link').fadeOut(300); 208 | $('span.highlighted').removeClass('highlighted'); 209 | }, 210 | 211 | /** 212 | * make the url absolute 213 | */ 214 | makeURL : function(relativeURL) { 215 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 216 | }, 217 | 218 | /** 219 | * get the current relative url 220 | */ 221 | getCurrentURL : function() { 222 | var path = document.location.pathname; 223 | var parts = path.split(/\//); 224 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 225 | if (this == '..') 226 | parts.pop(); 227 | }); 228 | var url = parts.join('/'); 229 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 230 | } 231 | }; 232 | 233 | // quick alias for translations 234 | _ = Documentation.gettext; 235 | 236 | $(document).ready(function() { 237 | Documentation.init(); 238 | }); 239 | -------------------------------------------------------------------------------- /docs/build/html/testing.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |Often times you will find yourself having images required in your models, and testing these models can be a real pain in the 51 | donkey as you will have to create images just for that.
52 |We want to make things simple for you, so you can import our method ‘create_dummy_image’ to easily create a dummy image for your tests!
53 |create_dummy_image(filename=u'Test_image', title=u'Title', caption=u'Caption', alt_text=u'Alt Text',
54 | credit=u'Credit'):
55 | This will create a new dummy entry in the database, so all you have to do is to assign it to your model’s Foreign Key.
58 |Remember to call
59 |image.delete()
60 | In your tearDown.
63 |Also, django_image_tools will never delete your images, so you will have to delete them yourself. 64 | Just kidding, we made a script for that too.
65 |delete_image(image)
66 | So, here’s a complete script.
69 |def setUp(self):
70 | partnerImage = create_dummy_image()
71 | model_with_image = Model(name=u'Coca cola', image=partnerImage)
72 | partner.save()
73 |
74 | def testInsert(self):
75 | self.assertEqual(Model.objects.all()[0].name, 'Coca cola')
76 |
77 | def tearDown(self):
78 | model_with_image = Model.objects.all()[0]
79 | delete_image(model_with_image.image)
80 | model_with_image.delete()
81 | Django Image Tools uses Travis CI to test the integration with several versions of Python and Django. 86 | You can see the list of currently supported combinations on our Travis CI page.
87 |