{
"tab_size": 4
}
.container-fluid
.table-responsive
table.table
</body>
а лучше даже c display: none;
people = models.ForeignKey(People, help_text = 'Фамилия, имя учащегося', on_delete = models.SET_NULL, null=True, related_name="peoples")
date_list = State.objects.all()
for obj in date_list:
for person in obj.peoples:
person.name
person.status
from django.db import models
from django.utils.translation import ugettext_lazy as _
class SchoolClass(models.Model):
name = models.CharField(
_('Класс'),
max_length=10,
db_index=True,
unique=True,
help_text=_('Название класса.'),
)
class Meta:
verbose_name = _('Класс')
verbose_name_plural = _('Классы')
def __str__(self):
return self.name
class Pupil(models.Model):
first_name = models.CharField(
_('Имя'),
max_length=100,
db_index=True,
help_text=_('Имя учащегося.'),
)
last_name = models.CharField(
_('Фамилия'),
max_length=100,
db_index=True,
help_text=_('Фамилия учащегося.'),
)
school_class = models.ForeignKey(
to=SchoolClass, on_delete=models.CASCADE,
verbose_name=_('Класс'), related_name='pupils',
help_text=_('Название класса.'),
)
class Meta:
verbose_name = _('Ученик')
verbose_name_plural = _('Ученики')
indexes = (
models.Index(fields=['first_name', 'last_name']),
)
def __str__(self):
return self.full_name
@property
def full_name(self):
return '{} {}'.format(self.first_name, self.last_name)
class Schedule(models.Model):
ATTEND = 'attend'
ABSENT = 'absent'
STATUS_CHOICES = (
(ATTEND, 'Присутствовал'),
(ABSENT, 'Отсутствовал'),
)
pupil = models.ForeignKey(
to=Pupil, on_delete=models.CASCADE,
verbose_name=_('Ученик'), related_name='schedules',
help_text=_('Фамилия и имя учащегося.')
)
date = models.DateField(
_('Дата'),
db_index=True,
help_text=_('Дата.')
)
status = models.CharField(
_('Статус'), max_length=10,
choices=STATUS_CHOICES, default=ABSENT,
db_index=True,
help_text=_('Статус.')
)
class Meta:
verbose_name = _('Расписание')
verbose_name_plural = _('Расписания')
indexes = (
models.Index(fields=['date', 'status']),
)
unique_together = ('pupil', 'date',)
from django.contrib import admin
from schedule.models import (
SchoolClass,
Pupil,
Schedule
)
class PupilInLIne(admin.TabularInline):
model = Pupil
fields = ('first_name', 'last_name')
extra = 1
class ScheduleInLIne(admin.TabularInline):
model = Schedule
fields = ('date', 'status')
extra = 1
@admin.register(SchoolClass)
class SchoolClassAdmin(admin.ModelAdmin):
list_display = ('name',)
list_display_links = ('name',)
inlines = (PupilInLIne,)
list_filter = ('name',)
search_fields = ('name',)
@admin.register(Pupil)
class PupilAdmin(admin.ModelAdmin):
list_display = ('full_name', 'school_class')
list_display_links = ('full_name',)
inlines = (ScheduleInLIne,)
raw_id_fields = ('school_class',)
list_select_related = ('school_class',)
search_fields = ('first_name', 'last_name', 'school_class__name')
list_filter = ('school_class__name',)
class PupilScheduleDetailView(DetailView):
model = Pupil
template_name = 'pupil_schedule_detail.html'
def get_context_data(self, **kwargs):
context_data = super().get_context_data(**kwargs)
schedule_queryset = self.object.schedules.all().select_related(
'pupil'
).values(
'pupil__first_name',
'pupil__last_name',
'date', 'status'
)
context_data.update({
'schedules': schedule_queryset
})
return context_data
{% if schedules %}
<table>
{% for schedule in schedules %}
<tr>
<td>{{ schedule.pupil__first_name }} {{ schedule.pupil__last_name }}</td>
<td>{{ schedule.date }}</td>
<td>{{ schedule.status }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>Данных нет!</p>
{% endif %}
In [13]: list(re.findall('%(\w+ *\w+)%', '\n1.%География Математика%(8:30-9:15)'))
Out[13]: ['География Математика']
In [14]: list(re.findall('%(\w+ *\w+)%', '\n1.%ГеографияМатематика%(8:30-9:15)'))
Out[14]: ['ГеографияМатематика']
In [15]: list(re.findall('%(.+)%', '\n1.%ГеографияМатематика%(8:30-9:15)'))
Out[15]: ['ГеографияМатематика']
In [16]: list(re.findall('%(.+)%', '\n1.%География Математика%(8:30-9:15)'))
Out[16]: ['География Математика']
...они упоминают привязку кода C++ к Java Script и я опять же совершенно не понимаю, как они могут взаимодействовать, как можно соединить эти два языка...Смотри какое крутое колдунство: тыц
from flask import Flask, request
import telebot
from telebot import types
import time
secret = "GUID"
bot = telebot.TeleBot('TOKEN_TELEGRAM', threaded=False)
bot.remove_webhook()
time.sleep(1)
bot.set_webhook(url="https://YOURNAME.pythonanywhere.com/{}".format(secret))
app = Flask(__name__)
@app.route('/{}'.format(secret), methods=["POST"])
def webhook():
bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
print("Message")
return "ok", 200
@bot.message_handler(commands=['start', 'help'])
def startCommand(message):
bot.send_message(message.chat.id, 'Hi *' + message.chat.first_name + '*!' , parse_mode='Markdown', reply_markup=types.ReplyKeyboardRemove())