Commit f77b00580669d76433da09f0ffe02709a2a454b2
Committed by
GitHub
1 parent
fa76f97b
Exists in
pdf_file_html
and in
1 other branch
Updated READ.ME
removi todos os itens que já estão presentes nos guias, assim não tem conteúdo repetido e algo mais organizado.
Showing
1 changed file
with
0 additions
and
256 deletions
Show diff stats
README.md
... | ... | @@ -80,262 +80,6 @@ Para Classes que envolvem formulários: |
80 | 80 | * `CreateCourseForm` |
81 | 81 | * `UpdateCourseForm()` |
82 | 82 | |
83 | -[PT-BR] | |
84 | -##API Descrição | |
85 | -Estamos usando em sua maioria viewsets ( http://www.django-rest-framework.org/api-guide/viewsets/) para construir os endpoints da nossa API. Ela tem como função compartilhar os dados da instância do Amadeus com aplicações credenciadas. | |
86 | - | |
87 | -##API Setup | |
88 | -**Criar aplicação** | |
89 | -* Vá para "/o/applications/" e clique "new application". Um formulário irá aparecer para preencher. | |
90 | -* No formulário, preencha somente o "Name" com o nome da aplicação, os campos "client id" e "client secret" são gerados automaticamente e não devem ser modificados. | |
91 | -"Client type" deve ser confidential, e "Authorization Grant Type" como " Resource owner password-based". | |
92 | - | |
93 | -**Obtendo um access Token** | |
94 | - | |
95 | -* Crie um request, usando um usuário valido, usando o seguinte abaixo (lembre-se que isso é um POST, estou usando um comando curl para fins de teste): | |
96 | -curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u"<client_id>:<client_secret>" http://amadeus/o/token/ | |
97 | - | |
98 | -* finalmente, com o seu access token, você pode testar um dos endpoints usando o template abaixo: | |
99 | -curl -H "Authorization: Bearer <your_access_token>" -X POST -d"username=foo&password=bar" http://localhost:8000/users/ (inserting a new user) | |
100 | - | |
101 | - | |
102 | -* model list(GET) = list all objects from that mode in pagination mode, each page has 10 | |
103 | -* model detail(GET) = give the details of the objects and most important fields of the ones objects its has relationships. | |
104 | -* model create | |
105 | - | |
106 | -**API Endpoints ** | |
107 | - | |
108 | -**Courses (URL: coursesapi)** | |
109 | -* course list ("/coursesapi/") | |
110 | -* course detail ("/coursesapi/id") (id is a parameter) | |
111 | - | |
112 | -**Subject (URL: subjectapi)** | |
113 | -* subject list ("/subjectapi/") | |
114 | -* subject detail ("/subjectapi/id") (id is a parameter) | |
115 | - | |
116 | -**Topic (URL: topicsapi)** | |
117 | -* topics list ("/topicsapi/") | |
118 | -* topic detail ("/topicsapi/id") (id is a parameter) | |
119 | - | |
120 | -**logs (URL: logs)** | |
121 | -* logs list ("/logs/") | |
122 | -* log detail ("/logs/id") (id is a parameter) | |
123 | - | |
124 | - | |
125 | -## Breadcrumbs | |
126 | -[PT-BR] | |
127 | - | |
128 | - | |
129 | -Os **breadcrumbs** reduzem o número de ações que um usuários precisa tomar para chegar a uma página de nível superior e melhorar o nível de encontrabilidade de seções e páginas. | |
130 | - | |
131 | -No amadeus estamos utilizando a lib [django-bootstrap-breadcrumbs](http://django-bootstrap-breadcrumbs.readthedocs.io/en/latest/) para oferecer essa facilidade aos nosso usuários. | |
132 | - | |
133 | -**Como usar:** | |
134 | - | |
135 | - | |
136 | -O pacote já se encontra instalado no projeto. Ele está na lista das dependências que se encontram no arquivo `requirements.txt`, que já foi instalado anteriormente. Então para usar a lib num template, você só precisa fazer o load da tag: ```{% load django_bootstrap_breadcrumbs %}``` | |
137 | - | |
138 | -O pacote assume que você tem uma boa organização de urls no seu projeto para que ele possa funcionar como esperado. Ele funciona a base herança de templates, como assim? | |
139 | - | |
140 | -No arquivo ```core > templates > base.html``` existe um bloco denominado ***breadcrumbs***, que é o bloco que deve ser alterado pelos templates que herdam do ```base.html```. O outro bloco que vem logo a seguir ***render_breadcrumbs*** é o bloco responsável por renderizar todo o HTML que é gerado pelo bloco enterior, e ele só deve ser usado uma única vez. | |
141 | -TODOS os arquivos que herdam do template ```base.html``` ou de outro template que herdou dele, deve implementar o bloco ***breadcrumbs***. | |
142 | - | |
143 | -***Exemplo*** | |
144 | - | |
145 | - | |
146 | -Como a nossa dashboard começa na app ```app```, é nesse app que foi feito a primeira herança do bloco ***breadcrumbs*** e a partir dalí todos os apps estendem dos templates dessa app. | |
147 | -Vamos ilustrar um exemplo de breadcrumbs que vai até a página de criar uma discilina dentro de um curso: | |
148 | - | |
149 | -```1 - home.html``` | |
150 | - | |
151 | - | |
152 | -O arquivo ```1``` se encontra na app ```app``` e ele faz herança do template ```base.html``` | |
153 | - | |
154 | - | |
155 | -```python | |
156 | -1 {% block breadcrumbs %} | |
157 | -2 | |
158 | -3 {% clear_breadcrumbs %} | |
159 | -4 {% breadcrumb 'Home' 'app:index' %} | |
160 | -5 | |
161 | -6 {% endblock %} | |
162 | -7 | |
163 | -8 {% block render_breadcrumbs %} | |
164 | -9 {% render_breadcrumbs %} | |
165 | -10 {% endblock %} | |
166 | -``` | |
167 | - | |
168 | -A linha 3 é responsável por 'limpar' todo o breadcrumbs feito anteriormente, ou seja, se existisse algum breadcrumbs no trmplate herdado por ```home.html```, ele não vai existir a partir desse template. Por isso é recomendado usar essa tag somente no template root do breadcrumbs, egg: na home. | |
169 | - | |
170 | -A linha 4, é onde a mágica acontece. É o breadcrumb da página em si. | |
171 | -O primeiro parâmetro da template tag: o 'Home', é o texto que vai ficar linkado(quando você estiver em uma outra página). Ele pode ser um texto, que tem que vir entres aspas, por exemplo 'Home', ou pode ser uma variavel do template que nesse caso não precisa de aspas. O segundo parâmetro é a url da página em que o template em questão vai ser exibida, ou seja, ele chama a sua própria ulr, como era de se esperar. | |
172 | - | |
173 | -***OBS:*** Se a url tivesse um parâmetro, ele devia ser passado como um terceiro argumento da template tag. | |
174 | - | |
175 | -***OBS2:*** A linha 9 só precisa ser chamado uma única vez e deve ser na template home, egg: os templates que não são o root do breadcrumbs não precisam subsvrever o bloco 'render_breadcrumbs' | |
176 | - | |
177 | -```2 - courses > templates > course > index.html``` | |
178 | - | |
179 | - | |
180 | -O arquivo ```2``` é o index da app ```courses``` e ele herda o template ```1```. | |
181 | - | |
182 | - | |
183 | -```python | |
184 | -1 {% block breadcrumbs %} | |
185 | -2 | |
186 | -3 {{ block.super }} | |
187 | -4 {% breadcrumb 'Courses' 'course:manage' %} | |
188 | -5 | |
189 | -6 {% endblock %} | |
190 | -``` | |
191 | - | |
192 | -A linha 3 traz todo o breadcrumbs que já foi feito anteriormente para a página corrente, e a linha 4 acrescenta um novo elemento na lista dos breadcrumbs. Observe que você não precisa se preocupar em dizer qual página está sendo exibida e nem costomizar nenhum HTML. A template tag já faz tudo isso por você. Você só precisa dar um nome para o link, chamar a ulr da página e passar algum parâmetro para a ulr(caso for preciso). | |
193 | - | |
194 | -```3 - courses > templates > course > view.html``` | |
195 | - | |
196 | - | |
197 | -O arquivo 3 é o template de um curso específico, e ele herda do template ```2```. | |
198 | - | |
199 | - | |
200 | -```python | |
201 | -1 {% block breadcrumbs %} | |
202 | -2 | |
203 | -3 {{ block.super }} | |
204 | -4 {% breadcrumb course 'course:view' course.slug %} | |
205 | -5 | |
206 | -6 {% endblock %} | |
207 | -``` | |
208 | - | |
209 | -Repare que o primeiro parâmetro agora é uma variavel do template que representa o nome do curso, e o terceiro parâmetro é um argumento para a url(eles não precisam de aspas). | |
210 | - | |
211 | -```4 - courses > templates > subject > create.html``` | |
212 | - | |
213 | - | |
214 | -O arquivo ```4``` é o template de criar uma disciplica e ele herda do template ```3```. | |
215 | - | |
216 | - | |
217 | - | |
218 | -```python | |
219 | -1 {% block breadcrumbs %} | |
220 | -2 {{ block.super }} | |
221 | -3 {% breadcrumb 'Create subject' 'course:create_subject' course.slug %} | |
222 | -4 {% endblock breadcrumbs %} | |
223 | -``` | |
224 | - | |
225 | -Feito isso o breadcrumbs da página 'Criar disciplina' fica da seguinte forma: | |
226 | - | |
227 | - | |
228 | - [Home]() / [Cursos]() / [Nome do Curso]() / Criar disciplina | |
229 | - | |
230 | - | |
231 | -[EN-SU] | |
232 | - | |
233 | - | |
234 | -**Breadcrumbs** reduce the number of actions a user needs to take to reach a top-level page and improve the level of reachability of sections and pages. | |
235 | - | |
236 | -In amadeus we are using lib [django-bootstrap-breadcrumbs](http://django-bootstrap-breadcrumbs.readthedocs.io/en/latest/) to offer this facility to our users. | |
237 | - | |
238 | - | |
239 | -**How to use:** | |
240 | - | |
241 | - | |
242 | -The package is already installed in the project. It is in the list of dependencies that are in the `requirements.txt` file, which has already been installed previously. So to use lib in a template, you just need to load the tag: ```{% load django_bootstrap_breadcrumbs %}``` | |
243 | - | |
244 | -The package assumes that you have a good organization of urls in your project so that it can work as expected. It works the base inheritance of templates, how so? | |
245 | - | |
246 | -In the file ```core > templates > base.html``` there is a block called ***breadcrumbs***, which is the block that should be changed by the templates that inherit from ``` base.html```. The other block coming soon ***render_breadcrumbs*** is the block responsible for rendering all the HTML that is generated by the enterior block, and it should only be used once. | |
247 | -ALL files that inherit from the template ```base.html``` or from another template that inherited from it, should implement the block ***breadcrumbs***. | |
248 | - | |
249 | - | |
250 | -***Example*** | |
251 | - | |
252 | - | |
253 | -As our dashboard starts in the app ```app```, it is in this app that was made the first inheritance of the block ***breadcrumbs*** and from there all the apps extend from the templates of this app. | |
254 | -Let's illustrate an example of breadcrumbs that goes up the page to create a subject within a course: | |
255 | - | |
256 | -```1 - home.html``` | |
257 | - | |
258 | - | |
259 | -The ```1``` file is found in the ```app``` app and it inherits from the ``` base.html``` template | |
260 | - | |
261 | - | |
262 | -``` Python | |
263 | -1 {% block breadcrumbs %} | |
264 | -2 | |
265 | -3 {% clear_breadcrumbs %} | |
266 | -4 {% breadcrumb 'Home' 'app: index' %} | |
267 | -5 | |
268 | -6 {% endblock %} | |
269 | -7 | |
270 | -8 {% block render_breadcrumbs %} | |
271 | -9 {% render_breadcrumbs %} | |
272 | -10 {% endblock %} | |
273 | -``` | |
274 | - | |
275 | -Line 3 is responsible for 'clearing' all previously made breadcrumbs, that is, if there were any breadcrumbs in the trmplate inherited by ``` home.html```, it will not exist from that template. So it is recommended to use this tag only in the breadcrumbs root template, egg: na home. | |
276 | - | |
277 | -Line 4, is where magic happens. It is the breadcrumb of the page itself. | |
278 | -The first parameter of the template tag: 'Home' is the text that will be linked (when you are on another page). It can be a text, which has to be enclosed in quotation marks, for example 'Home', or it can be a template variable that in this case does not need quotation marks. The second parameter is the url of the page in which the template in question is going to be displayed, that is, it calls its own ulr, as expected. | |
279 | - | |
280 | -***NOTE:*** If the url had a parameter, it should be passed as a third argument of the template tag. | |
281 | - | |
282 | -***NOTE 2:*** Line 9 only needs to be called once and should be in the template home, egg: non-root templates of breadcrumbs do not need to subscribe to the 'render_breadcrumbs' | |
283 | - | |
284 | -```2 - courses > templates > course > index.html``` | |
285 | - | |
286 | - | |
287 | -The ```2``` file is the index of the ```courses``` app and it inherits the ```1``` template. | |
288 | - | |
289 | - | |
290 | -``` python | |
291 | -1 {% block breadcrumbs %} | |
292 | -2 | |
293 | -3 {{ block.super }} | |
294 | -4 {% breadcrumb 'Courses' 'course: manage' %} | |
295 | -5 | |
296 | -6 {% endblock %} | |
297 | -``` | |
298 | - | |
299 | -Line 3 brings all the breadcrumbs that were previously made to the current page, and line 4 adds a new element to the breadcrumbs list. Note that you do not have to worry about which page is being displayed or costomising any HTML. The template tag does all this for you. You just need to give the link a name, call the ulr of the page and pass some parameter to the ulr (if necessary). | |
300 | - | |
301 | -```3 - courses > templates > course > view.html``` | |
302 | - | |
303 | - | |
304 | -File 3 is the template for a specific course, and it inherits from the ```2``` template. | |
305 | - | |
306 | - | |
307 | -``` python | |
308 | -1 {% block breadcrumbs %} | |
309 | -2 | |
310 | -3 {{ block.super }} | |
311 | -4 {% breadcrumb course 'course: view' course.slug %} | |
312 | -6 {% endblock %} | |
313 | -``` | |
314 | - | |
315 | -Notice that the first parameter is now a template variable that represents the course name, and the third parameter is an argument to the url (they do not need quotation marks). | |
316 | - | |
317 | -```4 - courses > templates > subject > create.html``` | |
318 | - | |
319 | - | |
320 | -The ```4``` file is the template for creating a discipline and it inherits from the ```3``` template. | |
321 | - | |
322 | - | |
323 | - | |
324 | -``` python | |
325 | -1 {% block breadcrumbs%} | |
326 | -2 {{ block.super }} | |
327 | -3 {% breadcrumb 'Create subject' 'course: create_subject' course.slug %} | |
328 | -4 {% endblock breadcrumbs %} | |
329 | -``` | |
330 | - | |
331 | -Once this is done, the breadcrumbs of the 'Create discipline' page is as follows: | |
332 | - | |
333 | - | |
334 | -[Home]() / [Courses]() / [Course Name]() / Create Subject | |
335 | - | |
336 | - | |
337 | - | |
338 | - | |
339 | 83 | |
340 | 84 | |
341 | 85 | ... | ... |