Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-sharelatex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
sed-rennes
sharelatex
python-sharelatex
Commits
184b41ea
Commit
184b41ea
authored
5 years ago
by
ANDRADE-BARROSO Guillermo
Committed by
SIMONIN Matthieu
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
first version of share project fonctions
parent
a72406a6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sharelatex/__init__.py
+25
-0
25 additions, 0 deletions
sharelatex/__init__.py
sharelatex/cli.py
+21
-0
21 additions, 0 deletions
sharelatex/cli.py
with
46 additions
and
0 deletions
sharelatex/__init__.py
+
25
−
0
View file @
184b41ea
...
...
@@ -359,6 +359,7 @@ class SyncClient:
# TODO(msimonin): return type
return
r
# TODO: check if this fonction is still usefull (in regard to get_doc)
def
get_document
(
self
,
project_id
,
doc_id
):
"""
Get a single document (e.g tex file).
...
...
@@ -533,6 +534,30 @@ class SyncClient:
raise
Exception
(
f
"
Uploading
{
path
}
fails
"
)
return
response
def
share
(
self
,
project_id
,
email
,
can_edit
=
True
):
"""
Send a invitation to share (edit/view) a project.
Args:
project_id (str): The project id of the project to share
email (str): Email of the recipient of the invitation
can_edit (boolean):True (resp. False) gives read/write (resp. read-only) access to the project
Returns:
response (dict) status of the request as returned by sharelatex
Raises:
Exception if something is wrong with the compilation
"""
url
=
f
"
{
self
.
base_url
}
/project/
{
project_id
}
/invite
"
data
=
{
"
email
"
:
email
,
"
privileges
"
:
"
readAndWrite
"
if
can_edit
else
"
readOnly
"
,
"
_csrf
"
:
self
.
csrf
}
r
=
self
.
client
.
post
(
url
,
data
=
data
,
verify
=
self
.
verify
)
r
.
raise_for_status
()
response
=
r
.
json
()
return
response
def
compile
(
self
,
project_id
):
"""
Trigger a remote compilation.
...
...
This diff is collapsed.
Click to expand it.
sharelatex/cli.py
+
21
−
0
View file @
184b41ea
...
...
@@ -255,6 +255,27 @@ def compile(project_id):
print
(
response
)
@cli.command
(
help
=
"
Send a invitation to share (edit/view) a project
"
)
@click.argument
(
"
email
"
,
default
=
""
)
@click.option
(
"
--project_id
"
,
default
=
None
)
@click.option
(
"
--can-edit/--read-only
"
,
default
=
True
,
help
=
"""
Authorize user to edit the project or not
"""
,
)
def
share
(
project_id
,
email
,
can_edit
):
repo
=
Repo
()
base_url
,
project_id
=
refresh_project_information
(
repo
,
project_id
=
project_id
)
username
,
password
=
refresh_account_information
(
repo
)
client
=
SyncClient
(
base_url
=
base_url
,
username
=
username
,
password
=
password
,
verify
=
True
)
response
=
client
.
share
(
project_id
,
email
,
can_edit
)
print
(
response
)
@cli.command
(
help
=
f
"""
Pull the files from sharelatex.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment