diff options
author | Teddy Wing | 2017-06-03 15:41:09 +0200 |
---|---|---|
committer | Teddy Wing | 2017-06-03 15:41:09 +0200 |
commit | f231e2836de8d0324fd0a6e4cd1861026de30104 (patch) | |
tree | 987d60a38c57efae6f1e36a71742852f2facf1ba | |
parent | 61c447fda6fe833bebb953600167975685e89102 (diff) | |
parent | 573df442661c9d0794688e1da98f1ef966ef6265 (diff) | |
download | timetasker-f231e2836de8d0324fd0a6e4cd1861026de30104.tar.bz2 |
Merge branch 'cleanup-from-single-time-entry-submission-work' into timetasker-daily
-rw-r--r-- | main.go | 27 | ||||
-rw-r--r-- | templates/timesheet.yml.tmpl | 11 | ||||
-rw-r--r-- | templates/weekly_timesheet.yml.tmpl | 3 | ||||
-rw-r--r-- | timetask/fields.go | 94 | ||||
-rw-r--r-- | timetask/generator.go | 44 | ||||
-rw-r--r-- | timetask/http.go | 4 | ||||
-rw-r--r-- | timetask/http_test.go | 2 | ||||
-rw-r--r-- | timetask/project.go | 10 | ||||
-rw-r--r-- | timetask/time_entry.go | 18 |
9 files changed, 22 insertions, 191 deletions
@@ -1,10 +1,8 @@ package main import ( - // "fmt" "io/ioutil" "log" - // "os" "time" "github.com/teddywing/timetasker/timetask" @@ -17,7 +15,7 @@ type Config struct { Username string PasswordCmd string `toml:"password_cmd"` } - Profile timetask.Profile + Profile timetask.Profile Projects map[string]timetask.Project } @@ -55,29 +53,6 @@ func main() { defer resp.Body.Close() body, err = ioutil.ReadAll(resp.Body) log.Println(string(body)) - - // if len(os.Args) == 1 { - // fmt.Println("Not enough arguments") - // os.Exit(1) - // } - // - // file_path := os.Args[len(os.Args)-1] - // file, err := ioutil.ReadFile(file_path) - // if err != nil { - // log.Println(err) - // } - - // time_entries := []timetask.TimeEntry{} - // err = yaml.Unmarshal(file, &time_entries) - // if err != nil { - // log.Println(err) - // } - // - // log.Printf("%+v", time_entries) - - // timetask.SubmitTimeEntries(config.Fields, time_entries) - - // timetask.GenerateWeeklyTimesheet(os.Stdout, config.Defaults) } func loadConfig() { diff --git a/templates/timesheet.yml.tmpl b/templates/timesheet.yml.tmpl deleted file mode 100644 index 1930b09..0000000 --- a/templates/timesheet.yml.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -{{- define "timesheet" -}} -- client: {{.Client}} - project: {{.Project}} - module: {{.Module}} - task: {{.Task}} - work_type: {{.WorkType}} - date: {{.Date.Format "02/01/06"}} - time: {{.Time}} - billable: {{.Billable}} - description: {{.Description}} -{{ end -}} diff --git a/templates/weekly_timesheet.yml.tmpl b/templates/weekly_timesheet.yml.tmpl deleted file mode 100644 index 0ea6582..0000000 --- a/templates/weekly_timesheet.yml.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -{{- range . -}} - {{- template "timesheet" . -}} -{{- end -}} diff --git a/timetask/fields.go b/timetask/fields.go deleted file mode 100644 index 9f7aa99..0000000 --- a/timetask/fields.go +++ /dev/null @@ -1,94 +0,0 @@ -package timetask - -// import "fmt" - -// type Client struct { -// ID int -// Name string -// Projects []Project -// } - -// type Project struct { -// ID int -// Name string -// Modules []Module -// Tasks []Task -// WorkTypes []WorkType `yaml:"work_types"` -// } - -type Project struct { - Client int - Project int - Module int - Task int - WorkType int `toml:"work_type"` - Billable bool -} - -// type Module struct { -// ID int -// Name string -// } -// type Task struct { -// ID int -// Name string -// } -// type WorkType struct { -// ID int -// Name string -// } -// -// type Fields struct { -// PersonID int `yaml:"person_id"` -// Clients []Client -// } -// -// func (f *Fields) ClientByName(client_name string) (*Client, error) { -// for _, client := range f.Clients { -// if client.Name == client_name { -// return &client, nil -// } -// } -// -// return nil, fmt.Errorf("Client %s not found", client_name) -// } -// -// func (c *Client) ProjectByName(project_name string) (*Project, error) { -// for _, project := range c.Projects { -// if project.Name == project_name { -// return &project, nil -// } -// } -// -// return nil, fmt.Errorf("Project %s not found", project_name) -// } -// -// func (p *Project) ModuleByName(module_name string) (*Module, error) { -// for _, module := range p.Modules { -// if module.Name == module_name { -// return &module, nil -// } -// } -// -// return nil, fmt.Errorf("Module %s not found", module_name) -// } -// -// func (p *Project) TaskByName(task_name string) (*Task, error) { -// for _, task := range p.Tasks { -// if task.Name == task_name { -// return &task, nil -// } -// } -// -// return nil, fmt.Errorf("Task %s not found", task_name) -// } -// -// func (p *Project) WorkTypeByName(work_type_name string) (*WorkType, error) { -// for _, work_type := range p.WorkTypes { -// if work_type.Name == work_type_name { -// return &work_type, nil -// } -// } -// -// return nil, fmt.Errorf("Work type %s not found", work_type_name) -// } diff --git a/timetask/generator.go b/timetask/generator.go deleted file mode 100644 index 5d0fa7f..0000000 --- a/timetask/generator.go +++ /dev/null @@ -1,44 +0,0 @@ -package timetask - -import ( - "io" - "log" - "text/template" - "time" - - "github.com/olebedev/when" - "github.com/olebedev/when/rules/common" - "github.com/olebedev/when/rules/en" -) - -func GenerateWeeklyTimesheet(wr io.Writer, defaults TimeEntry) { - w := when.New(nil) - w.Add(en.All...) - w.Add(common.All...) - - monday, err := w.Parse("last monday", time.Now()) - if err != nil { - log.Panic(err) - } - - time_entries := []TimeEntry{} - day := monday.Time - for i := 1; i <= 5; i++ { - time_entries = append(time_entries, defaults) - time_entries[len(time_entries) - 1].Date = day - day = day.AddDate(0, 0, 1) // Add 1 day - } - - t, err := template.ParseFiles( - "templates/weekly_timesheet.yml.tmpl", - "templates/timesheet.yml.tmpl", - ) - if err != nil { - log.Panic(err) - } - - err = t.Execute(wr, time_entries) - if err != nil { - log.Panic(err) - } -} diff --git a/timetask/http.go b/timetask/http.go index 736fcfb..6e73276 100644 --- a/timetask/http.go +++ b/timetask/http.go @@ -1,13 +1,10 @@ package timetask import ( - // "fmt" - // "log" "net/http" "net/http/cookiejar" "net/url" "strconv" - // "strings" "golang.org/x/net/publicsuffix" ) @@ -62,7 +59,6 @@ func SubmitTimeEntry( return resp, nil } - func buildSubmissionParams(time_entry TimeEntry) url.Values { v := url.Values{} diff --git a/timetask/http_test.go b/timetask/http_test.go index c54617f..604c3c3 100644 --- a/timetask/http_test.go +++ b/timetask/http_test.go @@ -17,6 +17,8 @@ func init() { } func TestLogin(t *testing.T) { + t.Skip("No requests") + response, err := Login(username, password) if err != nil { t.Fatal(err) diff --git a/timetask/project.go b/timetask/project.go new file mode 100644 index 0000000..b8fe5c7 --- /dev/null +++ b/timetask/project.go @@ -0,0 +1,10 @@ +package timetask + +type Project struct { + Client int + Project int + Module int + Task int + WorkType int `toml:"work_type"` + Billable bool +} diff --git a/timetask/time_entry.go b/timetask/time_entry.go index 161de3e..ff0ad1f 100644 --- a/timetask/time_entry.go +++ b/timetask/time_entry.go @@ -23,15 +23,15 @@ func NewTimeEntry( description string, ) TimeEntry { return TimeEntry{ - PersonID: profile.PersonID, - Client: project.Client, - Project: project.Project, - Module: project.Module, - Task: project.Task, - WorkType: project.WorkType, - Date: date, - Time: time, - Billable: project.Billable, + PersonID: profile.PersonID, + Client: project.Client, + Project: project.Project, + Module: project.Module, + Task: project.Task, + WorkType: project.WorkType, + Date: date, + Time: time, + Billable: project.Billable, Description: description, } } |