Commit 19a9158a authored by Claude Paroz's avatar Claude Paroz

[vertimus] Fix various errors

parent 268a2e96
......@@ -59,10 +59,10 @@ class LatestActionsByLanguage(Feed):
def item_link(self, item):
link = urlresolvers.reverse('vertimus_by_names',
args=(item.state.branch.module.name,
item.state.branch.name,
item.state.domain.name,
item.state.language.locale))
args=(item.state_db.branch.module.name,
item.state_db.branch.name,
item.state_db.domain.name,
item.state_db.language.locale))
return "%s#%d" % (link, item.id)
def item_pubdate(self, item):
......@@ -103,10 +103,10 @@ class LatestActionsByTeam(Feed):
def item_link(self, item):
link = urlresolvers.reverse('vertimus_by_names',
args=(item.state.branch.module.name,
item.state.branch.name,
item.state.domain.name,
item.state.language.locale))
args=(item.state_db.branch.module.name,
item.state_db.branch.name,
item.state_db.domain.name,
item.state_db.language.locale))
return "%s#%d" % (link, item.id)
def item_pubdate(self, item):
......
......@@ -345,6 +345,17 @@ class ActionAbstract(models.Model):
except:
return False
def merged_file(self):
"""If available, returns the merged file as a dict: {'url':'path':'filename'}"""
mfile_url = mfile_path = mfile_name = None
if self.file:
mfile_url = self.file.url[:-3] + ".merged.po"
mfile_path = self.file.path[:-3] + ".merged.po"
mfile_name = os.path.basename(mfile_path)
if not os.access(mfile_path, os.R_OK):
mfile_url = mfile_path = mfile_name = None
return {'url': mfile_url, 'path': mfile_path, 'filename': mfile_name}
@classmethod
def get_action_history(cls, state=None, sequence=None):
"""
......@@ -410,17 +421,6 @@ class Action(ActionAbstract):
arch_action = self.new_by_name('AA', person=self.person)
arch_action.apply_on(self.state_db)
def merged_file(self):
"""If available, returns the merged file as a dict: {'url':'path':'filename'}"""
mfile_url = mfile_path = mfile_name = None
if self.file:
mfile_url = self.file.url[:-3] + ".merged.po"
mfile_path = self.file.path[:-3] + ".merged.po"
mfile_name = os.path.basename(mfile_path)
if not os.access(mfile_path, os.R_OK):
mfile_url = mfile_path = mfile_name = None
return {'url': mfile_url, 'path': mfile_path, 'filename': mfile_name}
def get_previous_action_with_po(self):
"""
Return the previous Action with an uploaded file related to the
......
......@@ -147,7 +147,7 @@ def vertimus_diff(request, action_id_1, action_id_2, level):
else:
ActionReal = Action
action_1 = get_object_or_404(ActionReal, pk=action_id_1)
state = action_1.state
state = action_1.state_db
file_path_1 = action_1.merged_file()['path'] or action_1.file.path
reduced = is_po_reduced(file_path_1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment