# Path: RandoAmisSecours/models.py
# class Profile(models.Model):
#     class Meta:
#         app_label = 'RandoAmisSecours'
# 
#     user = models.OneToOneField(User)
#     friends = models.ManyToManyField('self', blank=True)
#     phone_number = models.CharField(max_length=30, blank=True, null=True)
#     provider = models.CharField(max_length=30, blank=True, null=True, choices=PROVIDERS)
#     provider_data = models.TextField(blank=True, null=True)
#     hash_id = models.CharField(unique=True, max_length=30, default=random_hash)
#     language = models.CharField(max_length=4, blank=True, null=True, choices=LANGUAGES)
#     timezone = models.CharField(max_length=40, choices=[(tz, tz) for tz in pytz.all_timezones], default='UTC')
# 
#     def clean(self):
#         if self.provider_data:
#             try:
#                 json.loads(self.provider_data)
#             except Exception:
#                 raise ValidationError({'provider_data': [ugettext('This should be JSON serialized')]})
# 
#         if self.timezone == 'UTC':
#             raise ValidationError({'timezone': [ugettext('UTC is not valid timezone')]})
# 
#     def __str__(self):
#         return "%s" % (self.user)
# 
# class FriendRequest(models.Model):
#     class Meta:
#         app_label = 'RandoAmisSecours'
# 
#     user = models.ForeignKey(User, related_name='+')
#     to = models.ForeignKey(User, related_name='+')
#     creation = models.DateTimeField(auto_now=True)
# 
#     def __str__(self):
#         return "%s => %s" % (self.user.get_full_name(), self.to.get_full_name())
# 
# Path: RandoAmisSecours/utils.py
# def send_localized_mail(user, subject, template_name, ctx):
#     with Localize(user.profile.language,
#                   user.profile.timezone):
#         send_mail_help(user, subject, template_name, ctx)


from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.utils.translation import ugettext as _
from RandoAmisSecours.models import Profile, FriendRequest
from RandoAmisSecours.utils import send_localized_mail
# -*- coding: utf-8 -*-
# vim: set ts=4

# Copyright 2013, 2014 Rémi Duraffort
# This file is part of RandoAmisSecours.
#
# RandoAmisSecours is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RandoAmisSecours is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with RandoAmisSecours.  If not, see <http://www.gnu.org/licenses/>

from __future__ import unicode_literals




@login_required
def search(request):

# Path: RandoAmisSecours/models.py
# class Profile(models.Model):
#     class Meta:
#         app_label = 'RandoAmisSecours'
# 
#     user = models.OneToOneField(User)
#     friends = models.ManyToManyField('self', blank=True)
#     phone_number = models.CharField(max_length=30, blank=True, null=True)
#     provider = models.CharField(max_length=30, blank=True, null=True, choices=PROVIDERS)
#     provider_data = models.TextField(blank=True, null=True)
#     hash_id = models.CharField(unique=True, max_length=30, default=random_hash)
#     language = models.CharField(max_length=4, blank=True, null=True, choices=LANGUAGES)
#     timezone = models.CharField(max_length=40, choices=[(tz, tz) for tz in pytz.all_timezones], default='UTC')
# 
#     def clean(self):
#         if self.provider_data:
#             try:
#                 json.loads(self.provider_data)
#             except Exception:
#                 raise ValidationError({'provider_data': [ugettext('This should be JSON serialized')]})
# 
#         if self.timezone == 'UTC':
#             raise ValidationError({'timezone': [ugettext('UTC is not valid timezone')]})
# 
#     def __str__(self):
#         return "%s" % (self.user)
# 
# class FriendRequest(models.Model):
#     class Meta:
#         app_label = 'RandoAmisSecours'
# 
#     user = models.ForeignKey(User, related_name='+')
#     to = models.ForeignKey(User, related_name='+')
#     creation = models.DateTimeField(auto_now=True)
# 
#     def __str__(self):
#         return "%s => %s" % (self.user.get_full_name(), self.to.get_full_name())
# 
# Path: RandoAmisSecours/utils.py
# def send_localized_mail(user, subject, template_name, ctx):
#     with Localize(user.profile.language,
#                   user.profile.timezone):
#         send_mail_help(user, subject, template_name, ctx)


# Path: RandoAmisSecours/views/friends.py
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.utils.translation import ugettext as _
from RandoAmisSecours.models import Profile, FriendRequest
from RandoAmisSecours.utils import send_localized_mail

# -*- coding: utf-8 -*-
# vim: set ts=4

# Copyright 2013, 2014 Rémi Duraffort
# This file is part of RandoAmisSecours.
#
# RandoAmisSecours is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RandoAmisSecours is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with RandoAmisSecours.  If not, see <http://www.gnu.org/licenses/>

from __future__ import unicode_literals




@login_required
def search(request):

    query = request.GET.get('query')