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.shortcuts import render, redirect, get_object_or_404 | |
import calendar | |
import datetime | |
def add_work_schedule_item(**data): | |
first_weekday, num_days_in_month = calendar.monthrange(2019, 2) | |
work_schedule = get_object_or_404(WorkSchedule, pk=3) | |
for day_number in range(1, num_days_in_month + 1): |
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 add_crm_mail(mail_from, mail_content): | |
typeofservice = Typeofservice.objects.filter(id=1) | |
client = Client.objects.filter(id=1) | |
for atendimento in client: | |
Atendimento.objects.get_or_create(type=typeofservice, | |
department='1', | |
person=client, | |
contact=mail_from, | |
feedback=mail_content) |
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
(cobradoronline) elias@eliasPai:~/cobradoronline$ heroku logs | |
2019-05-11T16:35:15.612960+00:00 app[web.1]: results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) | |
2019-05-11T16:35:15.612962+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1068, in execute_sql | |
2019-05-11T16:35:15.612963+00:00 app[web.1]: cursor.execute(sql, params) | |
2019-05-11T16:35:15.612965+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute | |
2019-05-11T16:35:15.612967+00:00 app[web.1]: return super().execute(sql, params) | |
2019-05-11T16:35:15.612968+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute | |
2019-05-11T16:35:15.612970+00:00 app[web.1]: return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) | |
2019-05-11T16:35:15.612972+00:00 app[web.1]: File "/app/.heroku/python/lib/python3 |
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
(cobradoronline) elias@eliasPai:~/cobradoronline$ heroku run python manage.py migrate | |
Running python manage.py migrate on ⬢ cobradoronline... up, run.6385 (Hobby) | |
/app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>. | |
""") | |
Operations to perform: | |
Apply all migrations: admin, auth, bolsa, bookings, contenttypes, person, sessions | |
Running migrations: | |
Applying bolsa.0017_auto_20181010_1059...Traceback (most recent call last): | |
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute | |
return self.cursor.execute(sql, params) |
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 datetime import datetime | |
with open('arquivo.txt', 'r', encoding='UTF-8', errors='surrogateescape') as fobj: | |
for line in fobj.readlines(): | |
try: | |
with open('alterdata.txt', 'a') as aobj: #Abre um novo arquivo chamado alterdata.txt | |
x = line.strip()[25:39] | |
t = line.strip()[26+x.index(':'):72] | |
aobj.write(line.strip()[:10]+ | |
'|'+ | |
line.strip()[11:24]+ |
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
{% extends "index.html" %} | |
{% load static %} | |
{% load material_form %} | |
{% load i18n %} | |
{% block container %} | |
<div class="col-md-12"> | |
<p> | |
<a href="{% url 'invoice_add' %}" class="btn btn-primary">Invoice list</a> | |
</p> | |
</div> |
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
# My models | |
class Invoice(models.Model): | |
customer = models.ForeignKey(Customer, on_delete=models.CASCADE) | |
total = models.IntegerField('Total') | |
created = models.DateTimeField('created', auto_now_add=True) | |
modified = models.DateTimeField('modified', auto_now=True) | |
def get_absolute_url(self): |
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
""" | |
Bom, a minha necessidade é poder mostrar contas.novo no template logo abaixo da última repetição de data conforme abaixo: | |
23/11/2019 COMPRA 300 | |
23/11/2019 VENDA 600 | |
TOTAL---------------- 100 | |
27/11/2019 COMPRA 2000 | |
TOTAL---------------- 2000 | |
29/11/2019 VENDA 100 | |
29/11/2019 VENDA 200 |
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
question_add = [ | |
{'os': '1558','nome_campo': 'VOLTAGEM', 'valor_campo': '100'}, | |
{'os': '1558','nome_campo': 'ROTA', 'valor_campo': 'LESTE'}, | |
{'os': '1558','nome_campo': 'VAGA', 'valor_campo': 'TRUE'}, | |
{'os': '1559','nome_campo': 'VOLTAGEM', 'valor_campo': '50'}, | |
{'os': '1560','nome_campo': 'AGENTE', 'valor_campo': 'ELIAS'}, | |
{'os': '1560','nome_campo': 'VOLTAGEM', 'valor_campo': '10'}, | |
{'os': '1561','nome_campo': 'VOLTAGEM', 'valor_campo': '17'} | |
] |
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 xlsxwriter | |
line_data = [ | |
['000001 ', 'Emitido', '-'] | |
['000002 ', '-', 'VALOR 03'] | |
['000003 ', '-', 'VALOR 03'] | |
] | |
# exportando para excel | |
workbook = xlsxwriter.Workbook('filename.xlsx') |