Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Allow custom week report numbering.
Browse files Browse the repository at this point in the history
  • Loading branch information
icedream committed Jun 19, 2017
1 parent 6e23997 commit 819e660
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
28 changes: 22 additions & 6 deletions export/latex/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,30 @@ func (e *Exporter) Export(prj *project.Project, w io.Writer) (err error) {
},
})

// Generate work report numbers
actualNumber := 0
weeknums := map[int]int{}
for i, week := range prj.Weeks {
actualNumber++

if week.Number > 0 {
// Use custom number for this week's report
actualNumber = week.Number
}

weeknums[i] = actualNumber
}

data := struct {
Project *project.Project
TexMarker TexMarker
TexInputs []string
Project *project.Project
TexMarker TexMarker
TexInputs []string
WeekNumbers map[int]int
}{
Project: prj,
TexInputs: e.Inputs,
TexMarker: e.Marker,
Project: prj,
TexInputs: e.Inputs,
TexMarker: e.Marker,
WeekNumbers: weeknums,
}
return exportTemplate.Execute(w, data)
}
2 changes: 1 addition & 1 deletion export/latex/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var exportTemplate = template.Must(template.
\tableofcontents
<range $index, $week := .Project.Weeks>
\begin{weeklyreport}{<add $index 1>}{<beginofweek $week.Date>}{<endofweek $week.Date>}
\begin{weeklyreport}{<index $.WeekNumbers $index>}{<beginofweek $week.Date>}{<endofweek $week.Date>}
\weeklyreportsection{<T "operational_activities">}
<with $week.WorkActivities>
Expand Down
3 changes: 2 additions & 1 deletion project/week.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package project
// Week represents a week in the report.
type Week struct {
Date Date
Number int `json:"Number,omitempty"`
Periods []Period `json:"Professional school"`
WorkActivities []string `json:"Operational activities"`
WorkActivityDetails string `json:"Operational instructions"`
Periods []Period `json:"Professional school"`
}

0 comments on commit 819e660

Please sign in to comment.