Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dorchies David
HaTaTA
Commits
7d60f6d0
Commit
7d60f6d0
authored
May 12, 2021
by
Dorchies David
Browse files
debug: try old fashion form post by getting cookies from the session (not working)
parent
5f16d33f
Changes
1
Hide whitespace changes
Inline
Side-by-side
R/add_temps.R
View file @
7d60f6d0
#'
Title
#'
Add a day time in "Feuille de pointage"
#'
#' @param cookies Connection cookies in string format or key/value vector
#' (See [set_cookie])
#' @param user_id ID of the user
#' session a [rvest::session] provided by [login] function
#' @param date Date to fill
#' @param duree Duration of the working day
#' @param type_regulation Regularisation type (default 22 for "Heures normales")
...
...
@@ -19,11 +17,8 @@
#' @examples
#' \dontrun{
#' library(hatata)
#' login("pnom", "my_password")
#' add_temps(
#' user_id = "4242",
#' date = "15/04/2021"
#' )
#' session <- login("pnom", "my_password")
#' add_temps(session, "15/04/2021")
#' }
add_temps
<-
function
(
session
,
...
...
@@ -31,21 +26,27 @@ add_temps <- function(
duree
=
"+07h44"
,
type_regulation
=
"22"
,
commentaire
=
""
,
user_id
=
get_user_id
(
session
),
cfg
=
config
::
get
(
file
=
system.file
(
"config.yml"
,
package
=
"hatata"
))
)
{
if
(
!
inherits
(
session
,
"hatata_pointage"
))
{
session
<-
jump_to_pointage
(
session
)
}
rs
<-
rvest
::
read_html
(
system.file
(
"form_add.html"
,
package
=
"hatata"
))
rf
<-
rvest
::
html_form
(
rs
)[[
1
]]
# Define proper url for form action
rf
$
action
<-
paste
(
cfg
$
url_post_add
,
cfg
$
param_add
,
sep
=
"?"
)
# Set form fields
rf
<-
rf
%>%
rvest
::
html_form_set
(
date
=
date
,
type_regulation
=
type_regulation
,
commentaire
=
commentaire
,
user_id
=
user_id
,
duree
=
duree
)
rvest
::
session_submit
(
session
,
rf
)
cookies
<-
session
$
response
$
cookies
$
value
names
(
cookies
)
<-
session
$
response
$
cookies
$
name
POST
(
paste
(
cfg
$
url_post_add
,
cfg
$
param_add
,
sep
=
"?"
),
#user_agent(cfg$user_agent),
set_cookies
(
.cookies
=
cookies
),
body
=
list
(
date
=
date
,
type_regulation
=
type_regulation
,
commentaire
=
commentaire
,
user_id
=
attr
(
session
,
"user_id"
),
id_form
=
"form_add_regul"
,
duree
=
duree
)
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment