Re: [Weblate] Query users via the API

2018-04-06 Thread Michal Čihař
Loïc Dachary píše v Pá 16. 03. 2018 v 22:18 +0100:
> Hi,
> 
> Is it possible to query the users via the API? I would like to write
> a script to manage the list of users who have permission to
> **Approve** strings. It does not seem to be possible via the weblate
> API but maybe there is a way to access the Django API with a user
> that has access to /admin/ ?

There is currently no API for user management. Feel free to open issue
for that in the issue tracker, it might get implemented when rewriting
the user database for the 3.0 release.

-- 
Michal Čihař | https://cihar.com/ | https://weblate.org/


signature.asc
Description: This is a digitally signed message part
___
Weblate mailing list
Weblate@lists.cihar.com
https://lists.cihar.com/cgi-bin/mailman/listinfo/weblate


Re: [Weblate] Query users via the API

2018-03-20 Thread Loïc Dachary
Hi,

For information I hacked something based on scrapy[1] to get the mail of all 
users that belong to the Localizationlab group:


import scrapy
import sys
from scrapy.crawler import CrawlerProcess

class WeblateSpider(scrapy.Spider):
name = "weblate"
start_urls = ['https://weblate.securedrop.club/accounts/login/']

def parse(self, response):
return scrapy.FormRequest.from_response(
response,
formdata={'username': sys.argv[1], 'password': sys.argv[2]},
callback=self.after_login)

def after_login(self, response):
assert response.css('#profile-button')
return scrapy.Request(
url='https://weblate.securedrop.club/admin/auth/user/',
callback=self.user_list)

def user_list(self, response):
next_page = 
response.xpath('//a[@title="Localizationlab"]/@href').extract_first()
return response.follow(next_page, self.localizationlab_list)

def localizationlab_list(self, response):
for mail in response.css('.field-email::text').extract():
print('A ' + str(mail))

process = CrawlerProcess({
'USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'
})

process.crawl(WeblateSpider)
process.start() # the script will block here until the crawling is finished
-

python script.py user passwordofuser

[1] https://scrapy.org/

On 03/16/2018 10:18 PM, Loïc Dachary wrote:
> Hi,
> 
> Is it possible to query the users via the API? I would like to write a script 
> to manage the list of users who have permission to **Approve** strings. It 
> does not seem to be possible via the weblate API but maybe there is a way to 
> access the Django API with a user that has access to /admin/ ?
> 
> Thanks in advance
> 
> 
> 
> ___
> Weblate mailing list
> Weblate@lists.cihar.com
> https://lists.cihar.com/cgi-bin/mailman/listinfo/weblate
> 

-- 
Loïc Dachary, Artisan Logiciel Libre



signature.asc
Description: OpenPGP digital signature
___
Weblate mailing list
Weblate@lists.cihar.com
https://lists.cihar.com/cgi-bin/mailman/listinfo/weblate