This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# located at #{Rails.root}/config/initializers/rails_admin.rb | |
# RailsAdmin config file. Generated on March 01, 2012 17:53 | |
# See github.com/sferik/rails_admin for more informations | |
RailsAdmin.config do |config| | |
config.current_user_method { current_user } # auto-generated | |
config.main_app_name = ['Timetracker', 'Admin'] | |
config.authorize_with do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Task < ActiveRecord::Base | |
# get an array with 0.0, 0.25, 0.50, 0.75, ... | |
@@hours_options = 0.step(3, 0.25).collect {|x| x} | |
belongs_to :proyect | |
# valudation rules | |
validates :hours, :inclusion => { :in => @@hours_options } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make our own testrunner that by default only tests our own apps | |
from django.conf import settings | |
from django.test.simple import DjangoTestSuiteRunner | |
class CustomTestRunner(DjangoTestSuiteRunner): | |
def build_suite(self, test_labels, *args, **kwargs): | |
return super(CustomTestRunner, self).build_suite(test_labels or settings.PROJECT_APPS, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError in Personal_invoices#show | |
Showing D:/PERFILES/Marquez/Jaratech/Workspace/branches/tt2-rails/app/views/personal_invoices/show.pdf.prawn where line #17 raised: | |
undefined method `headers=' for #<Prawn::Table:0x75612d8> | |
Extracted source (around line #17): | |
14: ["Email address", "#{@invoice.paypal_email}"] | |
15: ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_if_changed(model_instance, new_values): | |
has_changed = False | |
for field_name, field_value in new_values.items(): | |
old_value = getattr(model_instance, field_name) | |
if old_value != field_value: | |
setattr(model_instance, field_name, field_value) | |
has_changed = True | |
if has_changed: | |
model_instance.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Taken from (http://djangosnippets.org/snippets/1949/) | |
and made some adjustments for cases when queryset is empty | |
""" | |
import gc | |
def queryset_iterator(queryset, chunksize=1000): | |
''''' | |
Iterate over a Django Queryset ordered by the primary key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from django.db import models | |
class MyModel(models.Model): | |
# other fields... | |
start_date = models.DateTimeField() | |
unique_date = models.CharField(max_length=32, unique=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie.fields import DictField | |
from sorl.thumbnail import get_thumbnail | |
from sorl.thumbnail.helpers import ThumbnailError | |
class SorlThumbnailField(DictField): | |
""" | |
api field used to return a thumbnail generated with | |
sorl-thumbnail python library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global module:false*/ | |
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
/* --------------------------------------- */ | |
/* --( Variables )-- */ | |
/* --------------------------------------- */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(require, exports, module) { | |
var angular = require('angular'); | |
require('angular-cookies'); | |
var usersModule = module.exports = angular.module('users', ['ngCookies']) | |
.factory('UserService', ['$http', '$cookieStore', function($http, $cookieStore) { | |
var currentUser = $cookieStore.get('user') || null; |
OlderNewer