Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge commit '0b8fc2b24a52ad438ffb46c430419a92dc731524' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanata Build Server committed Mar 16, 2012
2 parents ce532e4 + 0b8fc2b commit 262ed49
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 252 deletions.
Expand Up @@ -32,40 +32,59 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.management.JpaIdentityStore;
import org.zanata.common.ContentState;
import org.zanata.common.EntityStatus;
import org.zanata.common.TransUnitWords;
import org.zanata.dao.ProjectIterationDAO;
import org.zanata.model.HAccount;
import org.zanata.model.HLocale;
import org.zanata.model.HProjectIteration;
import org.zanata.security.BaseSecurityChecker;
import org.zanata.service.LocaleService;

@Name("viewAllStatusAction")
@Scope(ScopeType.PAGE)
public class ViewAllStatusAction implements Serializable
public class ViewAllStatusAction extends BaseSecurityChecker implements Serializable
{
private static final long serialVersionUID = 1L;

@Logger
Log log;
private String iterationSlug;
private String projectSlug;

@In(required = false, value = JpaIdentityStore.AUTHENTICATED_USER)
HAccount authenticatedAccount;

@In
ProjectIterationDAO projectIterationDAO;

@In
LocaleService localeServiceImpl;

private String iterationSlug;

private String projectSlug;

private boolean showAllLocales = false;

private HProjectIteration projectIteration;


public static class Status implements Comparable<Status>
{
private String locale;
private String nativeName;
private TransUnitWords words;
private int per;
private boolean userInLanguageTeam;

public Status(String locale, String nativeName, TransUnitWords words, int per)
public Status(String locale, String nativeName, TransUnitWords words, int per, boolean userInLanguageTeam)
{
this.locale = locale;
this.nativeName = nativeName;
this.words = words;
this.per = per;
this.userInLanguageTeam = userInLanguageTeam;
}

public String getLocale()
Expand All @@ -87,6 +106,11 @@ public double getPer()
{
return per;
}

public boolean isUserInLanguageTeam()
{
return userInLanguageTeam;
}

@Override
public int compareTo(Status o)
Expand Down Expand Up @@ -115,18 +139,13 @@ public String getIterationSlug()
{
return this.iterationSlug;
}

public HProjectIteration getProjectIteration()
{
return projectIterationDAO.getBySlug(projectSlug, iterationSlug);
}

public List<Status> getAllStatus()
{
List<Status> result = new ArrayList<Status>();
HProjectIteration iteration = projectIterationDAO.getBySlug(this.projectSlug, this.iterationSlug);
Map<String, TransUnitWords> stats = projectIterationDAO.getAllWordStatsStatistics(iteration.getId());
List<HLocale> locale = localeServiceImpl.getSupportedLangugeByProjectIteration(this.projectSlug, this.iterationSlug);
List<HLocale> locale = this.getDisplayLocales();
Long total = projectIterationDAO.getTotalCountForIteration(iteration.getId());
for (HLocale var : locale)
{
Expand All @@ -147,11 +166,62 @@ public List<Status> getAllStatus()
per = (int) Math.ceil(100 * words.getApproved() / words.getTotal());

}
Status op = new Status(var.getLocaleId().getId(), var.retrieveNativeName(), words, per);
boolean isMember = authenticatedAccount != null ? authenticatedAccount.getPerson().isMember(var) : false;

Status op = new Status(var.getLocaleId().getId(), var.retrieveNativeName(), words, per, isMember);
result.add(op);
}
Collections.sort(result);
return result;
}

public boolean getShowAllLocales()
{
return showAllLocales;
}

public void setShowAllLocales(boolean showAllLocales)
{
this.showAllLocales = showAllLocales;
}

public HProjectIteration getProjectIteration()
{
if( this.projectIteration == null )
{
this.projectIteration = projectIterationDAO.getBySlug(projectSlug, iterationSlug);
}
return this.projectIteration;
}

public boolean isIterationReadOnly()
{
return this.getProjectIteration().getProject().getStatus() == EntityStatus.READONLY ||
this.getProjectIteration().getStatus() == EntityStatus.READONLY;
}

public boolean isIterationObsolete()
{
return this.getProjectIteration().getProject().getStatus() == EntityStatus.OBSOLETE ||
this.getProjectIteration().getStatus() == EntityStatus.OBSOLETE;
}

private List<HLocale> getDisplayLocales()
{
if( this.showAllLocales || authenticatedAccount == null )
{
return localeServiceImpl.getSupportedLangugeByProjectIteration(this.projectSlug, this.iterationSlug);
}
else
{
return localeServiceImpl.getTranslation(projectSlug, iterationSlug, authenticatedAccount.getUsername());
}
}

@Override
public Object getSecuredEntity()
{
return this.getProjectIteration();
}

}
3 changes: 3 additions & 0 deletions server/zanata-war/src/main/resources/messages.properties
Expand Up @@ -223,6 +223,8 @@ jsf.ImportJavaLocales=Import Java Locales
jsf.InvalidActivationKey=Invalid activation key
jsf.Version=Version
jsf.iteration.ShowAllLocales=Show All Locales
jsf.iteration.ShowAllLocales.title=Shows all available locales for this version (Teams for which you belong will be higlighted in yellow).
jsf.iteration.files.ConfirmDownloadAllFiles=Your download will be prepared and may take a few minutes to complete. Is this ok?
jsf.iteration.files.ContentType=Content Type
jsf.iteration.files.DownloadAllFiles=Download All Files (zip)
Expand Down Expand Up @@ -282,6 +284,7 @@ jsf.PoweredBy=Powered by
jsf.project.EditHomePage.label=Edit Page Code
jsf.project.EditHomePage.tooltip=Edit the Project's home page code as persisted. Useful when the home page cannot be edited via the project edit page.
jsf.project.ViewIteration=View >>

jsf.Projects=Projects
jsf.ProjectMaintainerManager=Project Maintainer Manager
Expand Down

This file was deleted.

51 changes: 26 additions & 25 deletions server/zanata-war/src/main/webapp/WEB-INF/pages.xml
Expand Up @@ -327,9 +327,10 @@
<action execute="#{identity.checkPermission(projectIterationHome.instance, 'insert')}" />
<navigation from-action="#{projectIterationHome.persist}">
<rule if="#{projectIterationHome.managed}">
<redirect view-id="/project/project.xhtml">
<param name="slug" value="#{projectIterationHome.projectSlug}" />
</redirect>
<redirect view-id="/iteration/iteration.xhtml">
<param name="projectSlug" value="#{projectIterationHome.projectSlug}"/>
<param name="iterationSlug" value="#{projectIterationHome.instance.slug}" />
</redirect>
</rule>
</navigation>
<navigation from-action="#{projectIterationHome.cancel}">
Expand All @@ -339,7 +340,22 @@
</navigation>
</page>

<page view-id="/project/iteration_edit.xhtml">
<!-- Project Iteration -->

<page view-id="/iteration/iteration.xhtml" >
<param name="projectSlug" value="#{viewAllStatusAction.projectSlug}" />
<param name="iterationSlug" value="#{viewAllStatusAction.iterationSlug}" />
</page>

<page view-id="/iteration/files.xhtml">
<param name="project" value="#{projectIterationFilesAction.projectSlug}" />
<param name="iteration" value="#{projectIterationFilesAction.iterationSlug}" />
<param name="localeId" value="#{projectIterationFilesAction.localeId}" />

<action execute="#{projectIterationFilesAction.initialize()}" />
</page>

<page view-id="/iteration/edit.xhtml">
<param name="slug" value="#{projectIterationHome.slug}" />
<param name="projectSlug" value="#{projectIterationHome.projectSlug}" />
<param name="slug" value="#{projectIterationLocaleAction.iterationSlug}" />
Expand All @@ -348,35 +364,20 @@
<!-- can't use <restrict> here either -->
<action execute="#{identity.checkPermission(projectIterationHome.instance, 'update')}" />
<navigation from-action="#{projectIterationHome.update}">
<redirect view-id="/project/project.xhtml">
<param name="slug" value="#{projectIterationHome.projectSlug}" />
<redirect view-id="/iteration/iteration.xhtml">
<param name="projectSlug" value="#{projectIterationHome.projectSlug}"/>
<param name="iterationSlug" value="#{projectIterationHome.slug}" />
</redirect>
</navigation>

<navigation from-action="#{projectIterationHome.cancel}">
<redirect view-id="/project/project.xhtml">
<param name="slug" value="#{projectIterationHome.projectSlug}" />
<redirect view-id="/iteration/iteration.xhtml">
<param name="projectSlug" value="#{projectIterationHome.projectSlug}"/>
<param name="iterationSlug" value="#{projectIterationHome.slug}" />
</redirect>
</navigation>
</page>

<page view-id="/project/iteration_status.xhtml" >
<param name="projectSlug" value="#{viewAllStatusAction.projectSlug}" />
<param name="iterationSlug" value="#{viewAllStatusAction.iterationSlug}" />
</page>

<page view-id="/project/iteration_files.xhtml">
<param name="project" value="#{projectIterationFilesAction.projectSlug}" />
<param name="iteration" value="#{projectIterationFilesAction.iterationSlug}" />
<param name="localeId" value="#{projectIterationFilesAction.localeId}" />

<param name="project" value="#{projectIterationZipFileAction.projectSlug}" />
<param name="iteration" value="#{projectIterationZipFileAction.iterationSlug}" />
<param name="localeId" value="#{projectIterationZipFileAction.localeId}" />

<action execute="#{projectIterationFilesAction.initialize()}" />
</page>


<!-- Language -->

Expand Down

0 comments on commit 262ed49

Please sign in to comment.