Skip to content

Instantly share code, notes, and snippets.

View gcavalcante8808's full-sized avatar

Gabriel Abdalla Cavalcante gcavalcante8808

View GitHub Profile
@gcavalcante8808
gcavalcante8808 / models.py
Created June 8, 2013 15:04
IronWiki --> models
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from mptt.models import MPTTModel, TreeForeignKey
#TODO: Handle the change agains current revision. At this moment, the change is manual.
class Article(MPTTModel):
"""
@gcavalcante8808
gcavalcante8808 / view.html
Created June 8, 2013 15:01
IronWiki - Template - ListView --> Article
{% extends "index.html" %}
{% load mptt_tags %}
{% load i18n %}
{% block wiki_breadcrumbs %}
{% recursetree nodes %}
{% if node.get_ancestors %}
{% for item in node.get_ancestors %}
<a href="{% url 'get' item.id %}">{{ item }}</a>
<span class="divider">/</span>
@gcavalcante8808
gcavalcante8808 / views.py
Created June 8, 2013 14:59
IronWiki - Views - Article
class ArticleView(ListView):
model = Article
template_name = 'wiki/view.html'
def get_queryset(self, article_id=None):
article_id = self.kwargs.get("article_id")
self.queryset = Article.objects.filter(id=article_id)
return self.queryset
def get_context_data(self, **kwargs):
@gcavalcante8808
gcavalcante8808 / urls.py
Created April 24, 2012 13:39
Exemplo Views.py --> Urls Amigáveis
from django.conf.urls.defaults import *
urlpatterns = patterns ('',
(r'^divulgacao/(?P<slug_categoria>[\w_-]+)/(?P<slug_divulgacao>[\w_-]+)/$', 'CAMINHOPARAAVIEW'),
)
Environment:
Request Method: POST
Request URL: http://localhost:8000/admin/core/domaincredential/add/
Django Version: 1.4b1
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',