2019-03-06 16:22:05 +01:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
2017-06-25 18:00:15 +02:00
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
import html5lib
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
from combo.data.models import TextCell
|
|
|
|
|
|
|
|
|
|
DOCS = {
|
|
|
|
|
'passerelle-connecteur-dev': "https://dev.entrouvert.org/projects/passerelle/wiki/D%C3%A9veloppement_d'un_connecteur.html",
|
2017-06-30 12:42:09 +02:00
|
|
|
|
'passerelle-json-data-store': "https://dev.entrouvert.org/projects/passerelle/wiki/Stockage_de_donn%C3%A9es_JSON.html",
|
2017-12-07 09:43:50 +01:00
|
|
|
|
'combo-json-cell': "https://dev.entrouvert.org/projects/combo/wiki/D%C3%A9veloppement_d'une_cellule_aliment%C3%A9e_par_JSON.html",
|
2018-02-16 14:08:11 +01:00
|
|
|
|
'developer-installation': "https://dev.entrouvert.org/projects/publik-devinst/wiki/Installation_d'un_environnement_de_développement_local.html",
|
2018-10-23 17:39:19 +02:00
|
|
|
|
'redmine-contribuer-a-publik': "https://dev.entrouvert.org/projects/publik/wiki/Contribuer_%C3%A0_Publik.html",
|
2017-06-25 18:00:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 16:07:10 +01:00
|
|
|
|
for cell in TextCell.objects.filter(slug__in=DOCS.keys(), page__snapshot__isnull=True):
|
2017-06-25 18:00:15 +02:00
|
|
|
|
resp = requests.get(DOCS[cell.slug])
|
|
|
|
|
if resp.status_code != 200:
|
|
|
|
|
continue
|
|
|
|
|
document = BeautifulSoup(resp.content, 'html5lib')
|
|
|
|
|
content = document.find('body')
|
2019-10-25 00:37:47 +02:00
|
|
|
|
new_content = content.decode().replace('<body>', '').replace('</body>', '')
|
2017-06-25 18:00:15 +02:00
|
|
|
|
cell.text = new_content
|
2019-03-06 16:22:05 +01:00
|
|
|
|
cell.order = 1
|
|
|
|
|
cell.save()
|
|
|
|
|
|
2019-10-25 00:37:47 +02:00
|
|
|
|
url = DOCS[cell.slug].replace('.html', '')
|
2019-03-06 16:22:05 +01:00
|
|
|
|
cell, created = TextCell.objects.get_or_create(
|
|
|
|
|
page=cell.page,
|
|
|
|
|
slug='editor-warning', defaults={'order': 0})
|
|
|
|
|
cell.placeholder = 'content'
|
|
|
|
|
cell.order = 0
|
|
|
|
|
cell.text = u'''<div class="note note-tip"><div>Cette page est tirée de redmine, l'édition se fait là :<br>
|
|
|
|
|
<a href="%s">%s</a>.</div></div>''' % (url, url)
|
|
|
|
|
cell.public = False
|
2017-06-25 18:00:15 +02:00
|
|
|
|
cell.save()
|