def dashboard_profile(req): # user profile guaranteed to be created during openid login profile = req.user.get_profile() profile_form = get_session_form(req.session, ProfileForm, instance=profile) license_form = get_session_form(req.session, LicenseForm, instance=profile.default_license) context = { 'profile_form': profile_form, 'license_form': license_form, 'profile': profile, 'site_default_license': License.get_default(), } return render(req, "dashboard/profile.html", context)
def dashboard_create_album(req): album = Album(user=req.user) form = get_session_form(req.session, AlbumForm, instance=album) context = { 'album_form': form, } return render(req, "dashboard/create_album.html", context)
def album(req, album_id=None): album = get_object_or_404(Album, pk=album_id) comment_form = get_session_form(req.session, PartialCommentForm) page_number = req.GET.get('page', 1) page = get_page(album.user_images.public_only(req.user), 4 * 3, page_number) context = { 'album': album, 'comment_form': comment_form, 'image_page': page, 'request': req, } if album.is_public() or (album.user == req.user and req.user.is_authenticated()): template = 'album/view.html' #elif SharedHideable.objects.filter(shared_with=req.user.id, hideable=album).count(): # template = 'album/view.html' else: messages.error( req, "Sorry, you don't have permission to view this content.") template = 'album/permission_denied.html' return render(req, template, context)
def album(req, album_id=None): album = get_object_or_404(Album, pk=album_id) comment_form = get_session_form(req.session, PartialCommentForm) page_number = req.GET.get("page", 1) page = get_page(album.user_images.public_only(req.user), 4 * 3, page_number) context = {"album": album, "comment_form": comment_form, "image_page": page, "request": req} if album.is_public() or (album.user == req.user and req.user.is_authenticated()): template = "album/view.html" # elif SharedHideable.objects.filter(shared_with=req.user.id, hideable=album).count(): # template = 'album/view.html' else: messages.error(req, "Sorry, you don't have permission to view this content.") template = "album/permission_denied.html" return render(req, template, context)
def user_image(req, user_image_id=None): uimage = get_object_or_404(UserImage, pk=user_image_id) job = uimage.get_best_job() calib = None if job: calib = job.calibration #license_form = get_session_form(req.session, PartialLicenseForm) comment_form = get_session_form(req.session, PartialCommentForm) tag_form = get_session_form(req.session, TagForm) images = {} dim = uimage.image.get_display_image() images['original_display'] = reverse( 'astrometry.net.views.image.serve_image', kwargs={'id': dim.id}) images['original'] = reverse('astrometry.net.views.image.serve_image', kwargs={'id': uimage.image.id}) image_type = 'original' if job: if job.calibration: images['annotated_display'] = reverse('annotated_image', kwargs={ 'jobid': job.id, 'size': 'display' }) images['annotated'] = reverse('annotated_image', kwargs={ 'jobid': job.id, 'size': 'full' }) images['sdss_display'] = reverse('sdss_image', kwargs={ 'calid': job.calibration.id, 'size': 'display' }) images['sdss'] = reverse('sdss_image', kwargs={ 'calid': job.calibration.id, 'size': 'full' }) images['galex_display'] = reverse('galex_image', kwargs={ 'calid': job.calibration.id, 'size': 'display' }) images['galex'] = reverse('galex_image', kwargs={ 'calid': job.calibration.id, 'size': 'full' }) images['redgreen_display'] = reverse('red_green_image', kwargs={ 'job_id': job.id, 'size': 'display' }) images['redgreen'] = reverse('red_green_image', kwargs={ 'job_id': job.id, 'size': 'full' }) images['enhanced_display'] = reverse('enhanced_image', kwargs={ 'job_id': job.id, 'size': 'display' }) images['enhanced'] = reverse('enhanced_image', kwargs={ 'job_id': job.id, 'size': 'full' }) image_type = 'annotated' images['extraction_display'] = reverse( 'astrometry.net.views.image.extraction_image', kwargs={ 'job_id': job.id, 'size': 'display' }) images['extraction'] = reverse( 'astrometry.net.views.image.extraction_image', kwargs={ 'job_id': job.id, 'size': 'full' }) image_type = req.GET.get('image', image_type) if image_type in images: display_url = images[image_type + '_display'] fullsize_url = images[image_type] flags = Flag.objects.all() if req.user.is_authenticated(): selected_flags = [ flagged_ui.flag for flagged_ui in FlaggedUserImage.objects.filter( user_image=uimage, user=req.user, ) ] else: selected_flags = None logmsg(uimage.get_absolute_url()) context = { 'request': req, 'display_image': dim, 'image': uimage, 'job': job, 'calib': calib, 'comment_form': comment_form, #'license_form': license_form, 'tag_form': tag_form, 'images': simplejson.dumps(images), 'display_url': display_url, 'fullsize_url': fullsize_url, 'image_type': image_type, 'flags': flags, 'selected_flags': selected_flags, } if uimage.is_public() or (req.user.is_authenticated() and uimage.user == req.user): template = 'user_image/view.html' #elif SharedHideable.objects.filter(shared_with=req.user.id, hideable=image).count(): # template = 'user_image/view.html' else: messages.error( req, "Sorry, you don't have permission to view this content.") template = 'user_image/permission_denied.html' return render_to_response(template, context, context_instance=RequestContext(req))
def user_image(req, user_image_id=None): uimage = get_object_or_404(UserImage, pk=user_image_id) job = uimage.get_best_job() calib = None if job: calib = job.calibration #license_form = get_session_form(req.session, PartialLicenseForm) comment_form = get_session_form(req.session, PartialCommentForm) tag_form = get_session_form(req.session, TagForm) images = {} dim = uimage.image.get_display_image() images['original_display'] = reverse('serve_image', kwargs={'id': dim.id}) images['original'] = reverse('serve_image', kwargs={'id': uimage.image.id}) image_type = 'original' if job: if job.calibration: images['annotated_display'] = reverse('annotated_image', kwargs={ 'jobid': job.id, 'size': 'display' }) images['annotated'] = reverse('annotated_image', kwargs={ 'jobid': job.id, 'size': 'full' }) images['sdss_display'] = reverse('sdss_image', kwargs={ 'calid': job.calibration.id, 'size': 'display' }) images['sdss'] = reverse('sdss_image', kwargs={ 'calid': job.calibration.id, 'size': 'full' }) images['galex_display'] = reverse('galex_image', kwargs={ 'calid': job.calibration.id, 'size': 'display' }) images['galex'] = reverse('galex_image', kwargs={ 'calid': job.calibration.id, 'size': 'full' }) images['redgreen_display'] = reverse('red_green_image', kwargs={ 'job_id': job.id, 'size': 'display' }) images['redgreen'] = reverse('red_green_image', kwargs={ 'job_id': job.id, 'size': 'full' }) #images['enhanced_display'] = reverse('enhanced_image', kwargs={'job_id':job.id,'size':'display'}) #images['enhanced'] = reverse('enhanced_image', kwargs={'job_id':job.id,'size':'full'}) image_type = 'annotated' images['extraction_display'] = reverse('extraction_image', kwargs={ 'job_id': job.id, 'size': 'display' }) images['extraction'] = reverse('extraction_image', kwargs={ 'job_id': job.id, 'size': 'full' }) image_type = req.GET.get('image', image_type) if image_type in images: display_url = images[image_type + '_display'] fullsize_url = images[image_type] flags = Flag.objects.all() if req.user.is_authenticated(): selected_flags = [ flagged_ui.flag for flagged_ui in FlaggedUserImage.objects.filter( user_image=uimage, user=req.user, ) ] else: selected_flags = None if job and job.calibration: parity = (calib.get_parity() < 0) wcs = calib.raw_tan if calib.tweaked_tan is not None: wcs = calib.tweaked_tan imgurl = req.build_absolute_uri(images['original']) thumburl = req.build_absolute_uri(images['original_display']) fits = uimage.image.disk_file.is_fits_image() y = wcs.imageh - wcs.crpix2 orient = wcs.get_orientation() print('Parity', parity, 'FITS', fits, 'Orientation', orient) if parity: orient = 360. - orient wwturl = 'http://www.worldwidetelescope.org/wwtweb/ShowImage.aspx?reverseparity=%s&scale=%.6f&name=%s&imageurl=%s&credits=Astrometry.net+User+(All+Rights+Reserved)&creditsUrl=&ra=%.6f&dec=%.6f&x=%.1f&y=%.1f&rotation=%.2f&thumb=%s' % ( parity, wcs.get_pixscale(), uimage.original_file_name, imgurl, wcs.crval1, wcs.crval2, wcs.crpix1, y, orient, thumburl) else: wwturl = None logmsg(uimage.get_absolute_url()) context = { 'request': req, 'display_image': dim, 'image': uimage, 'job': job, 'calib': calib, 'comment_form': comment_form, #'license_form': license_form, 'tag_form': tag_form, 'images': simplejson.dumps(images), 'display_url': display_url, 'fullsize_url': fullsize_url, 'image_type': image_type, 'flags': flags, 'selected_flags': selected_flags, 'wwt_url': wwturl, } if uimage.is_public() or (req.user.is_authenticated() and uimage.user == req.user): template = 'user_image/view.html' #elif SharedHideable.objects.filter(shared_with=req.user.id, hideable=image).count(): # template = 'user_image/view.html' else: messages.error( req, "Sorry, you don't have permission to view this content.") template = 'user_image/permission_denied.html' return render(req, template, context)
def user_image(req, user_image_id=None): uimage = get_object_or_404(UserImage, pk=user_image_id) job = uimage.get_best_job() calib = None if job: calib = job.calibration #license_form = get_session_form(req.session, PartialLicenseForm) comment_form = get_session_form(req.session, PartialCommentForm) tag_form = get_session_form(req.session, TagForm) images = {} dim = uimage.image.get_display_image() images['original_display'] = reverse('astrometry.net.views.image.serve_image', kwargs={'id':dim.id}) images['original'] = reverse('astrometry.net.views.image.serve_image', kwargs={'id':uimage.image.id}) image_type = 'original' if job: if job.calibration: images['annotated_display'] = reverse('annotated_image', kwargs={'jobid':job.id,'size':'display'}) images['annotated'] = reverse('annotated_image', kwargs={'jobid':job.id,'size':'full'}) images['sdss_display'] = reverse('sdss_image', kwargs={'calid':job.calibration.id,'size':'display'}) images['sdss'] = reverse('sdss_image', kwargs={'calid':job.calibration.id,'size':'full'}) images['galex_display'] = reverse('galex_image', kwargs={'calid':job.calibration.id,'size':'display'}) images['galex'] = reverse('galex_image', kwargs={'calid':job.calibration.id,'size':'full'}) images['redgreen_display'] = reverse('red_green_image', kwargs={'job_id':job.id,'size':'display'}) images['redgreen'] = reverse('red_green_image', kwargs={'job_id':job.id,'size':'full'}) images['enhanced_display'] = reverse('enhanced_image', kwargs={'job_id':job.id,'size':'display'}) images['enhanced'] = reverse('enhanced_image', kwargs={'job_id':job.id,'size':'full'}) image_type = 'annotated' images['extraction_display'] = reverse('astrometry.net.views.image.extraction_image', kwargs={'job_id':job.id,'size':'display'}) images['extraction'] = reverse('astrometry.net.views.image.extraction_image', kwargs={'job_id':job.id,'size':'full'}) image_type = req.GET.get('image', image_type) if image_type in images: display_url = images[image_type + '_display'] fullsize_url = images[image_type] flags = Flag.objects.all() if req.user.is_authenticated(): selected_flags = [flagged_ui.flag for flagged_ui in FlaggedUserImage.objects.filter( user_image=uimage, user=req.user, ) ] else: selected_flags = None logmsg(uimage.get_absolute_url()) context = { 'request': req, 'display_image': dim, 'image': uimage, 'job': job, 'calib': calib, 'comment_form': comment_form, #'license_form': license_form, 'tag_form': tag_form, 'images': simplejson.dumps(images), 'display_url': display_url, 'fullsize_url': fullsize_url, 'image_type': image_type, 'flags': flags, 'selected_flags': selected_flags, } if uimage.is_public() or (req.user.is_authenticated() and uimage.user == req.user): template = 'user_image/view.html' #elif SharedHideable.objects.filter(shared_with=req.user.id, hideable=image).count(): # template = 'user_image/view.html' else: messages.error(req, "Sorry, you don't have permission to view this content.") template = 'user_image/permission_denied.html' return render_to_response(template, context, context_instance = RequestContext(req))
def user_image(req, user_image_id=None): uimage = get_object_or_404(UserImage, pk=user_image_id) job = uimage.get_best_job() calib = None if job: calib = job.calibration #license_form = get_session_form(req.session, PartialLicenseForm) comment_form = get_session_form(req.session, PartialCommentForm) tag_form = get_session_form(req.session, TagForm) images = {} dim = uimage.image.get_display_image() images['original_display'] = reverse('serve_image', kwargs={'id':dim.id}) images['original'] = reverse('serve_image', kwargs={'id':uimage.image.id}) image_type = 'original' if job: if job.calibration: images['annotated_display'] = reverse('annotated_image', kwargs={'jobid':job.id,'size':'display'}) images['annotated'] = reverse('annotated_image', kwargs={'jobid':job.id,'size':'full'}) images['sdss_display'] = reverse('sdss_image', kwargs={'calid':job.calibration.id,'size':'display'}) images['sdss'] = reverse('sdss_image', kwargs={'calid':job.calibration.id,'size':'full'}) images['galex_display'] = reverse('galex_image', kwargs={'calid':job.calibration.id,'size':'display'}) images['galex'] = reverse('galex_image', kwargs={'calid':job.calibration.id,'size':'full'}) images['redgreen_display'] = reverse('red_green_image', kwargs={'job_id':job.id,'size':'display'}) images['redgreen'] = reverse('red_green_image', kwargs={'job_id':job.id,'size':'full'}) #images['enhanced_display'] = reverse('enhanced_image', kwargs={'job_id':job.id,'size':'display'}) #images['enhanced'] = reverse('enhanced_image', kwargs={'job_id':job.id,'size':'full'}) image_type = 'annotated' images['extraction_display'] = reverse('extraction_image', kwargs={'job_id':job.id,'size':'display'}) images['extraction'] = reverse('extraction_image', kwargs={'job_id':job.id,'size':'full'}) image_type = req.GET.get('image', image_type) if image_type in images: display_url = images[image_type + '_display'] fullsize_url = images[image_type] flags = Flag.objects.all() if req.user.is_authenticated(): selected_flags = [flagged_ui.flag for flagged_ui in FlaggedUserImage.objects.filter( user_image=uimage, user=req.user, ) ] else: selected_flags = None if job and job.calibration: parity = (calib.get_parity() < 0) wcs = calib.raw_tan if calib.tweaked_tan is not None: wcs = calib.tweaked_tan imgurl = req.build_absolute_uri(images['original']) thumburl = req.build_absolute_uri(images['original_display']) fits = uimage.image.disk_file.is_fits_image() y = wcs.imageh - wcs.crpix2 orient = wcs.get_orientation() print('Parity', parity, 'FITS', fits, 'Orientation', orient) if parity: orient = 360. - orient wwturl = 'http://www.worldwidetelescope.org/wwtweb/ShowImage.aspx?reverseparity=%s&scale=%.6f&name=%s&imageurl=%s&credits=Astrometry.net+User+(All+Rights+Reserved)&creditsUrl=&ra=%.6f&dec=%.6f&x=%.1f&y=%.1f&rotation=%.2f&thumb=%s' % (parity, wcs.get_pixscale(), uimage.original_file_name, imgurl, wcs.crval1, wcs.crval2, wcs.crpix1, y, orient, thumburl) else: wwturl = None logmsg(uimage.get_absolute_url()) context = { 'request': req, 'display_image': dim, 'image': uimage, 'job': job, 'calib': calib, 'comment_form': comment_form, #'license_form': license_form, 'tag_form': tag_form, 'images': simplejson.dumps(images), 'display_url': display_url, 'fullsize_url': fullsize_url, 'image_type': image_type, 'flags': flags, 'selected_flags': selected_flags, 'wwt_url': wwturl, } if uimage.is_public() or (req.user.is_authenticated() and uimage.user == req.user): template = 'user_image/view.html' #elif SharedHideable.objects.filter(shared_with=req.user.id, hideable=image).count(): # template = 'user_image/view.html' else: messages.error(req, "Sorry, you don't have permission to view this content.") template = 'user_image/permission_denied.html' return render(req, template, context)