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
public class MessageBroadCast extends BroadcastReceiver { | |
String tag = "Mensagem"; | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
Bundle extras = intent.getExtras(); | |
try { | |
if(extras != null){ | |
Log.i(tag, "Mensagem" + extras.getString("param1", "Nada")); | |
} | |
} catch (Exception e) { |
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 get_form(self, request, obj=None, **kwargs): | |
self.exclude = [] | |
usuario = Usuario(user=request.user).get_user() | |
try: | |
if not request.user.is_superuser: | |
if usuario.estabelecimento: | |
self.fields["cidade"].queryset = Cidade.objects.filter(pk=usuario.cidade.pk) | |
self.readonly_fields = ('atrativo', 'cidade', 'estabelecimento') | |
# Verificar como setar os valores para os campos cidade e estabelecimento | |
else: |
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
<form class="form" role="form" id="form-send-mail" name="formContact" novalidate> | |
{% csrf_token %} | |
<div class="form-group"> | |
<label for="name">Nome</label> | |
<input type="text" class="form-control" required id="name" name="name" placeholder="Nome" data-ng-model="dataForm.nome"> | |
<br> | |
<label for="phone">Telefone</label> | |
<input type="text" class="form-control" id="phone" name="phone" data-ng-model="dataForm.telefone"> | |
<br> | |
<label for="subject">Assunto</label> |
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
from django.conf.urls import patterns | |
urlpatterns = patterns('company.views', | |
(r'^$', 'index'), | |
(r'sobre/$', 'about_us'), | |
(r'contato/$', 'contact'), | |
(r'sendmail/', 'send_mail'), | |
) |
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 send_mail(request): | |
u"""Method for send contact""" | |
return_response = {} | |
try: | |
print request.POST, request.GET | |
return_response['resposta'] = request.POST | |
except Exception, e: | |
return_response['resposta'] = e | |
finally: | |
return HttpResponse(json.dumps(return_response), |
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
$scope.sendMail = function(){ | |
$http( | |
{ | |
method: 'POST', | |
data: $.param($scope.dataForm), | |
url: '/company/sendmail/', | |
headers: { | |
'X-CSRFToken': $cookies['csrftoken'] | |
} | |
}).success(function(data, status, headers, config){ |
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
public class ConvertDate : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo cultureInfo) | |
{ | |
try | |
{ | |
if (value != null) | |
{ | |
// TODO Verificar como realizar a conversão sem gerar exception | |
string[] date_time_split = value.ToString().Split('T'); |
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 process_file_kml(sender, created, instance, **kwargs): | |
try: | |
if created: | |
xmldoc = minidom.parse(instance.shape_file) | |
document_name = \ | |
xmldoc.getElementsByTagName("kml")[0].getElementsByTagName("Document")[0].getElementsByTagName("name")[ | |
0] | |
type_shape = None | |
for place in xmldoc.getElementsByTagName("Placemark"): | |
name_place = place.getElementsByTagName("name")[0].firstChild.data |
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
# Create your models here. | |
class Abastecimento(models.Model): | |
valor_etanol = models.DecimalField("Valor Etanol", max_digits=9, decimal_places=2) | |
valor_gasolina = models.DecimalField("Valor Gasolina", max_digits=9, decimal_places=2) | |
valor_diesel = models.DecimalField("Valor Diesel", max_digits=9, decimal_places=2) | |
usuario = models.ForeignKey(Usuario, blank=True, null=True) | |
posto = models.ForeignKey('Posto', blank=True, null=True) | |
def __unicode__(self): | |
return u"Posto: %s - Valores: Gas R$ %s Alc R$ %s Die R$ %s" % (self.posto, self.valor_gasolina, self.valor_etanol, self.valor_diesel) |
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 AbastecimentoSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Abastecimento | |
fields = ('posto', 'valor_etanol', 'valor_gasolina', 'valor_diesel') | |
depth = 2 |