Skip to content

Instantly share code, notes, and snippets.

View oscarcp's full-sized avatar
🛠️
Building

Oscar Carballal oscarcp

🛠️
Building
View GitHub Profile
@oscarcp
oscarcp / spaces.py
Last active December 17, 2015 02:58
The new edit_roles function. All is expalined in the code doc.
def edit_roles(request, space_url):
"""
The edit_role function works to provide a way for space administrators to
modify the users roles inside a space, at the space level.
It basically works as an AJAX communication where the frontend sends to key
values: userid and perm, containing the user ID and the permission code,
which later we compare with the permissions dictionary. If the user has the
permission we go to the next one and so on.
@oscarcp
oscarcp / permissions.py
Created August 30, 2012 09:49
e-cidadania: Nice way of checking permissions across a model in django
# -*- coding: utf-8 -*-
#
# Copyright (c) 2010-2012 Cidadania S. Coop. Galega
#
# This file is part of e-cidadania.
#
# e-cidadania is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@oscarcp
oscarcp / Pyhango.conf
Created June 25, 2012 15:25
PyJango config
###
# Determines the bot's default nick.
#
# Default value: supybot
###
supybot.nick: Pyjango
###
# Determines what alternative nicks will be used if the primary nick
# (supybot.nick) isn't available. A %s in this nick is replaced by the
@oscarcp
oscarcp / debate_board.js
Created June 20, 2012 21:42
Optimize this
function addTableColumn() {
/*
addTableColumn() - Create a new column ny creating a new sortable TD in
all the rows.
*/
var tableID = $('table').attr('id');
var inputs = $('#' + tableID + ' input').length;
var tdlength = $('#' + tableID + ' td').length;
var criteriacount = $('#' + tableID + ' th[id^=debate-vcriteria]').length;
var formCount = parseInt($('#id_colform-TOTAL_FORMS').val());
@oscarcp
oscarcp / generate-docs.py
Created June 15, 2012 14:05
e-cidadania documentation generator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" This script download the latest git version of e-cidadania, compiles
the documentation and places it in the documentation website
"""
import sys
import os
import subprocess