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
var maxfiles = {{ maxfiles }}; // {{ maxfiles }} returns from views.py | |
$(function() { | |
$("#uploader").pluploadQueue({ | |
runtimes : 'gears', // Initialize gears runtime | |
url : '{{ obj.get_image_upload_url }}', // Url to current object image uploading url | |
max_file_size : '4mb', | |
chunk_size: '4mb', | |
multiple_queues : true, | |
multi_selection: false, // It's necessary for file uploading limit | |
rename: 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
@login_required | |
def delete(request, msg_pk): | |
msg = get_object_or_404(Message, pk=msg_pk) | |
## is owner? | |
if request.user != msg.user and request.user != msg.to: | |
raise Http404() | |
# Sender or Receiver ? | |
if msg.delete_status == 2: | |
msg.delete_status = 3 | |
elif request.user == msg.user and request.user != msg.to: |
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 clean(self): | |
from decimal import Decimal | |
cleaned_data = self.cleaned_data | |
price_mode = cleaned_data.get('price_mode') | |
price = cleaned_data.get('price') | |
if price_mode == u'0': | |
if price: | |
return self.cleaned_data['price'] | |
return self.cleaned_data['price_mode'] | |
else: |
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 django.contrib import admin | |
from django.db import models | |
class Item(models.Model): | |
name = models.CharField(max_length=60) | |
created = models.DateTimeField(auto_now_add=True) | |
priority = models.IntegerField(default=0) | |
difficulty = models.IntegerField(default=0) | |
done = models.BooleanField(default=False) |
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
const std::vector<std::string> toStdVector(const QVector<QString> &q_vect) | |
{ | |
std::vector<string> std_vect; | |
for (int i = 0; i < q_vect.size(); ++i) { | |
std_vect.push_back(q_vect[i].toStdString()); | |
} | |
return std_vect; | |
} |
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
const std::map<std::string, std::string> fromQMap(const QMap<QString, QString> &q_map) | |
{ | |
std::map<std::string, std::string> std_map; | |
QMap<QString, QString>::const_iterator i = q_map.constBegin(); | |
while (i != q_map.constEnd()) { | |
std_map.insert(std::pair<std::string, std::string>(i.key().toStdString(), i.value().toStdString())); | |
} | |
return std_map; | |
} |
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
const std::vector<std::string> fromQVector(const QVector<QString> &qVect) | |
{ | |
std::vector<std::string> stdVect; | |
for (int i = 0; i < qVect.size(); ++i) { | |
stdVect.push_back(qVect[i].toStdString()); | |
} | |
return stdVect; | |
} | |
const std::map<std::string, std::string> Aria2c::fromQMap(const QMap<QString, QString> &qMap) |
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
__author__ = 'alireza' | |
import re | |
import datetime | |
f = open('/home/alireza/countries.sql') | |
matches = re.findall(r"'([A-Z]{0,2})','([A-Z,. \"\(\)\-]+)','([\w\\,. \"\(\)\-]+)','?([A-Z]{0,4})'?,'?([\w]{0,4})'?", | |
f.read()) |
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 forwards(self, orm): | |
""" | |
Slugify all the country.printable_name and put them in slug field | |
""" | |
from django.template.defaultfilters import slugify | |
for country in orm.Country.objects.all(): | |
country.slug = slugify(country.printable_name) | |
countey.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
Traceback (most recent call last): | |
File "manage.py", line 14, in <module> | |
execute_manager(settings) | |
File "~/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager | |
utility.execute() | |
File "~/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute | |
self.fetch_command(subcommand).run_from_argv(self.argv) | |
File "~/venv/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv | |
self.execute(*args, **options.__dict__) | |
File "~/venv/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute |