This file contains hidden or 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
# coding: utf-8 | |
from django.conf import settings | |
from django.views.generic.simple import direct_to_template | |
from django.http import HttpResponseRedirect | |
from django.core.urlresolvers import reverse | |
from django.core.mail import send_mail | |
from django.shortcuts import get_object_or_404 |
This file contains hidden or 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
# coding: utf-8 | |
from django.conf import settings | |
from django.views.generic.simple import direct_to_template | |
from django.http import HttpResponseRedirect | |
from django.core.urlresolvers import reverse | |
from django.core.mail import send_mail | |
from django.shortcuts import get_object_or_404 |
This file contains hidden or 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
################### views.py | |
def _get_csv(request, from_date, to_date): | |
response = HttpResponse(mimetype='text/csv') | |
response['Content-Disposition'] = 'attachment; filename="reports-%s/%s.csv"' % (from_date,to_date) | |
for client in request.GET.getlist('client[]'): | |
account = Accounts.objects.all().filter( | |
client_id = client |
This file contains hidden or 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
Billing.getCsv = function() { | |
var self = this; | |
// Take care of the url | |
var url = this.options.csv_serviceUrl; | |
url = url.replace('?from_date', this.$dateFrom.attr('data-value')); | |
url = url.replace('?to_date', this.$dateTo.attr('data-value')); | |
$.ajax({ | |
url: url, | |
type: 'GET', |
This file contains hidden or 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 _parsedData(self, context): | |
totalmbs_miss = 0 | |
total_hits_miss = 0 | |
total_mbs = int(self.bytes_sent) | |
if self.upstream_cache_status in ['MISS', 'EXPIRED']: | |
totalmbs_miss = total_mbs | |
total_hits_miss = 1 | |
my_key = (self.date, self.hour, self.client_id, self.type, context.hostname) |
This file contains hidden or 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
######## LOG CONF ############# | |
logFolder = "/var/log/azion/" | |
logFileSize = 10000000 #10MB in bytes | |
#number of log files before rotate | |
logRotate = 10 | |
# loglevel: info, warning, error, critical, debug #KEEP MINIMUN LOG LEVEL critical for monitoring propose | |
loglevel = "debug" | |
def logMaker(logFile, logName = "Default"): |
This file contains hidden or 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
#forms.py | |
class ContactsEscalationForm(forms.ModelForm): | |
class Meta: | |
Model = ContactsEscalation | |
exclude = ('dt_cancel',) | |
#models.py |
This file contains hidden or 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
#admin.py | |
def save_model(self, request, obj, form, change): | |
""" | |
Add the admin user to a special model attribute for reference after save | |
""" | |
#obj._history_user = request.user | |
from cuser.middleware import CuserMiddleware | |
CuserMiddleware.set_user(request.user) | |
super(SimpleHistoryAdmin, self).save_model(request, obj, form, change) |
This file contains hidden or 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 httplib | |
__author__ = 'charles.sartori' | |
from django.contrib.contenttypes.models import ContentType | |
from django.test import TestCase | |
from django.contrib.auth.models import User | |
from mockito import mock, any, when | |
from model_mommy import mommy |
This file contains hidden or 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 IPField(models.Field): | |
__metaclass__ = models.SubfieldBase | |
description = 'IP Field' | |
def get_db_prep_value(self, value, connection, prepared=False): | |
value = super(IPField, self | |
).get_db_prep_value(value, connection, prepared) | |
if value is not None: | |
tmp = ipaddr.IPAddress(value) | |
if ':' in value: |
OlderNewer