Skip to content

Commit

Permalink
Show image width info in despeckle
Browse files Browse the repository at this point in the history
(Just the get_context() part. The method was also rewritten to take the
page as a parameer because, well, it kind of has to.)
  • Loading branch information
dellsystem committed Jun 14, 2012
1 parent fddb7fa commit d155dcf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions rodan/jobs/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import utils
from rodan.models.jobs import JobType, JobBase

gamera.core.init_gamera()


@utils.rodan_task(inputs='tiff')
def despeckle(image_filepath, **kwargs):
Expand Down Expand Up @@ -43,3 +45,10 @@ class Despeckle(JobBase):
'despeckle_value': 100
}
task = despeckle

def get_context(self, page):
latest_image_path = page.get_latest_file_path('tiff')
image = gamera.core.load_image(latest_image_path)
return {
'width': image.size.width,
}
2 changes: 1 addition & 1 deletion rodan/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class name and just convert it to lowercase.
"""
return self.slug or self.get_name().lower()

def get_context(self):
def get_context(self, page):
"""
Override this if you want to pass custom variables to the template.
Will be accessible in the template as "context" (so if you return
Expand Down
4 changes: 2 additions & 2 deletions rodan/models/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def __unicode__(self):
def get_absolute_url(self):
return ('rodan.views.jobs.view', self.slug)

def get_view(self):
def get_view(self, page):
"""
Returns a tuple of the template to use and a context dictionary
"""
return ('jobs/%s.html' % self.slug, self.get_object().get_context())
return ('jobs/%s.html' % self.slug, self.get_object().get_context(page))

def get_object(self):
return rodan.jobs.jobs[self.module]
Expand Down
2 changes: 1 addition & 1 deletion rodan/views/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def task(request, job_slug, project_id=0):
page.start_next_job(user=rodan_user)

job_object = job.get_object()
view_data = job.get_view()
view_data = job.get_view(page)
data = {
'project': project,
'job': job,
Expand Down

0 comments on commit d155dcf

Please sign in to comment.