Commit 0f6e8f27 authored by Olivier Girardot's avatar Olivier Girardot

upgraded branch from stef/nnmon master

parents 8fbc104c 5f64b380
......@@ -6,4 +6,5 @@
build/
nnmon.egg-info/
# ignore sqlite db
nnmon.db
*.db
*.pyc
nnmon the bugtracker for teh internetz
======================================
nnmon is the project running [respectmynet.eu](http://respectmynet.eu/).
Installation
------------
See [/docs/SETUP.md](nnmon/blob/master/docs/SETUP.md)
#from django.contrib.auth.models import User
from tastypie import fields
from tastypie.authorization import DjangoAuthorization
from tastypie.resources import ModelResource, ALL#, ALL_WITH_RELATIONS
from bt.models import Violation
#class UserResource(ModelResource):
# class Meta:
# queryset = User.objects.all()
# resource_name = 'auth/user'
# excludes = ['email', 'password', 'is_superuser']
class APIResource(ModelResource):
# user = fields.ForeignKey(UserResource, 'user')
class Meta:
queryset = Violation.objects.all()
list_allowed_methods = ['get', 'post']
detail_allowed_methods = ['get', 'post', 'put', 'delete']
resource_name = 'violations'
authorization = DjangoAuthorization()
filtering = {
'country': ALL,
'operator': ALL,
'activationid': ALL,
}
......@@ -188,11 +188,12 @@ def add(request):
'violations': v_list },
context_instance=RequestContext(request))
def ajax(request, country=None, operator=None):
if not operator:
return HttpResponse(json.dumps(sorted(list(set([x.operator for x in Violation.objects.filter(country=country,activationid='')])))))
else:
return HttpResponse(json.dumps(sorted(list(set([x.contract for x in Violation.objects.filter(country=country,activationid='',operator=operator)])))))
# XXX obsoleted by API
#def ajax(request, country=None, operator=None):
# if not operator:
# return HttpResponse(json.dumps(sorted(list(set([x.operator for x in Violation.objects.filter(country=country,activationid='')])))))
# else:
# return HttpResponse(json.dumps(sorted(list(set([x.contract for x in Violation.objects.filter(country=country,activationid='',operator=operator)])))))
def index(request):
v_list = Violation.objects.filter(activationid='',featuredcase__isnull=False).order_by('id').reverse()[:3]
......
SETUP
=====
This describes how to setup the nnmon dev environment
Install the base dependencies
-----------------------------
Install the following packages:
sudo aptitude install python-sqlite python-ooolib python-imaging
Install the base python virtualenv tools:
sudo apt-get install python-setuptools
sudo pip install virtualenv
sudo pip install virtualenvwrapper
You don't use the virtualenv/virtualenvwrapper tools yet
--------------------------------------------------------
Create a directory to hold the virtual environments:
mkdir ~/.virtualenvs
Add to your .bashrc (or equivalent) the following lines:
export WORKON_HOME=$HOME'/.virtualenvs'
source /usr/local/bin/virtualenvwrapper.sh
Then run the following command:
source ~/.bashrc
This will end up creating (relatively large) folders in ~/.virtualenvs
where all the projet dependencies will be installed.
Setup your virtual environment
-----------------------------
Create the virtualenv for nnmon and workon it:
mkvirtualenv --system-site-packages --distribute nnmon
Install nnmon's depdendencies:
pip install -r pip-requirements.txt
Run the server
--------------
cd ../nnmon
python manage.py syncdb # run the database migrations
python manage.py runserver 8080
Your application is available on [http://localhost:8080/](http://localhost:8080/)
......@@ -10,3 +10,4 @@ PIL>=1.1.7
flup>=1.0.3.dev-20110405
BeautifulSoup>=3.2.0
python-twitter==0.8.2
django-tastypie
......@@ -139,6 +139,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'tastypie',
)
TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
......
......@@ -5,6 +5,10 @@ from django.contrib import admin
from bt import views as bt
from bt.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
from bt.api import APIResource
api_resource = APIResource()
admin.autodiscover()
......@@ -18,9 +22,6 @@ urlpatterns = patterns('',
url(r'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$',
view=bt.filter_violations,
name="filter"),
url(r'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$',
view=bt.ajax,
name="ajax_call"),
url(r'^add/$',
view=bt.add,
name="add_violation"),
......@@ -78,6 +79,8 @@ urlpatterns = patterns('',
include('captcha.urls')),
url(r'^admin/',
include(admin.site.urls)),
url(r'^api/',
include(api_resource.urls)),
)
if settings.DEV_SERVER:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment