Welcome to DGAP Services’s documentation!

Indices and tables

core package

Submodules

core.admin module

class core.admin.ActionListFilter(request, params, model, model_admin)[source]

Bases: django.contrib.admin.filters.SimpleListFilter

lookups(request, model_admin)[source]
parameter_name = 'action_flag'
queryset(request, queryset)[source]
title = 'Действие'
class core.admin.LogEntryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

action_description(obj)[source]
date_hierarchy = 'action_time'
fieldsets = (('Metadata', {'fields': ('action_time', 'user_link', 'action_description', 'object_link')}), ('Detail', {'fields': ('get_change_message', 'content_type', 'object_id', 'object_repr')}))
get_actions(request)[source]
get_change_message(obj)[source]
get_queryset(request)[source]
has_add_permission(request)[source]
has_change_permission(request, obj=None)[source]
has_delete_permission(request, obj=None)[source]
list_display = ['action_time', 'user_link', 'content_type', 'object_link', 'action_description', 'get_change_message']
list_filter = [<class 'core.admin.UserListFilter'>, 'content_type', <class 'core.admin.ActionListFilter'>]
media
readonly_fields = ['id', 'action_time', 'user', 'content_type', 'object_id', 'object_repr', 'action_flag', 'change_message', 'object_link', 'action_description', 'user_link', 'get_change_message']
search_fields = ['object_repr', 'change_message']
class core.admin.UserListFilter(request, params, model, model_admin)[source]

Bases: django.contrib.admin.filters.SimpleListFilter

lookups(request, model_admin)[source]
parameter_name = 'user'
queryset(request, queryset)[source]
title = 'staff user'

core.context_processors module

core.context_processors.resolver_context_processor(request)[source]

core.local_settings module

core.settings module

Django settings for core project.

For more information on this file, see https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see https://docs.djangoproject.com/en/1.6/ref/settings/

core.urls module

class core.urls.MyRegistrationView(**kwargs)[source]

Bases: registration.backends.simple.views.RegistrationView

success_url = '/profiles'

Module contents

blog package

Provides simple blog functionality. Article data is stored in blog.models.Article and can be rendered as django template.

Subpackages

blog.templatetags package

Submodules
blog.templatetags.blog_extras module

Some custom templatetags simplifying article rendering in templates

blog.templatetags.blog_extras.article_content(slug)[source]

Simple temlatetag to retrieve article’s content by slug. If article is django template, it’s content is rendered

blog.templatetags.blog_extras.article_panel(slug, header_link=False, show_creation_time=False)[source]

Incluision tag that renders article content. Base template is ``blog/article_panel. Currently is basic bootstrap panel

This templatetag is used in blog/article_list.html, blog/article_detail.html.

Parameters:
  • slug (str) – article’s slug
  • header_link (bool) – If True then article header is a link to blog.views.ArticleDetail
  • show_creation_time (bool) – If True then publication datetime is shown.
Returns:

rendered article template

blog.templatetags.blog_extras.article_title(slug)[source]

Simple temlatetag to retrieve article’s content by slug. If article is django template, it’s content is rendered

blog.templatetags.blog_extras.get_article(slug)[source]

Templatetag that returns article (variable with all article data) by it’s slug.

Can be used in templates to manualy display article on a page

Parameters:slug (str) – Article’s slug
Return Article:blog.models.Article instance
Module contents

Submodules

blog.admin module

class blog.admin.ArticleAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Article admin class. New articles are created by moderators via this page

form

alias of ArticleAdminForm

save_model(request, obj, form, change)[source]

Sets object author as request.user

blog.forms module

Forms for article app

class blog.forms.ArticleAdminForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

Basic form for article change_view. Replaces text input with WYSISYG editor

blog.models module

This module defines models for blog app

class blog.models.Article(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Describes model for storing articles. Can render it’s content as Django template.

author

Article author, relates to profiles.models.UserProfile

content

Article content. Can store html (including Django templates). Behaviour is defined by is_django_template.

get_absolute_url()[source]

Get URL of this article

Returns:URL
hidden

True if article is hidden from regular users. See is_visible().

is_django_template

True if article should be rendered as Django template. See rendered_content()

is_visible(user: django.contrib.auth.models.User)[source]

Checks if specified user van ciew this post. E.g. post is published, of user is staff & so on

Parameters:user (User) – User to be checked
Returns:True if User can view this post, else False
Return type:bool
publish_dttm

Publication Date and time. Auto populated at article creation.

rendered_content

Renders self.content as Django template.

Parameters:context (Context) – Additional context to be passed to template
Returns:Rendered template
show_in_feed

True if article should appear in feeds such as blog.views.ArticleList

slug

models.SlugField storing user-friendly article URL

title

Article title.

Don’t insert HTML tags like <h3> - it’s rendered in templates. But, you may apply some text formatting like <b>.

blog.tests module

blog.urls module

URL dispatcher for blog app

Used urls: * Empty url redirects to news feed. See blog.views.ArticleList * post/<slug> and <slug> show detailed view of article (blog.views.ArticleDetail). The first one is kept to keep old urls valid

blog.views module

class blog.views.ArticleDetail(**kwargs)[source]

Bases: django.views.generic.detail.DetailView

Detailed view of article.

Base template is blog/article_detail.html.

get_context_data(**kwargs)[source]

Raises 403 error if user can’t view this article. See Article.is_visible()

model

alias of Article

class blog.views.ArticleList(**kwargs)[source]

Bases: django.views.generic.list.ListView

Blog’s newsfeed. Shows all visible articles with show_in_feed == True

Base temlate is blog/article_list.html.

get_context_data(**kwargs)[source]

Returns list of articles to be shown in feed. See blog.models.Article params for details

model

alias of Article

Module contents

fin_aid package

Subpackages

fin_aid.templatetags package

Submodules
fin_aid.templatetags.fin_aid_extras module
fin_aid.templatetags.fin_aid_extras.filename(value)[source]
fin_aid.templatetags.fin_aid_extras.register = <django.template.library.Library object>

@register.simple_tag def month_info():

text = “Сейчас: {}, Лимит: {:.0f}, Использовано: {:.0f}, Профицит: {:.0f}, Рассмаатривается: {:.0f}” current = MonthlyData.current() used = current.sum_used waiting = AidRequest.objects.filter(status=AidRequest.WAITING).aggregate(Sum(‘req_sum’))[‘req_sum__sum’] if not used:

used = 0

return text.format(current.get_month_display(), current.limit, used, current.limit - used, waiting)

month_info.allow_tags = True

Module contents

Submodules

fin_aid.admin module

class fin_aid.admin.AidDocumentInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.TabularInline

media
model

alias of AidDocument

class fin_aid.admin.AidRequestAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

class Media[source]

Bases: object

css = {'all': ('//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css',)}
js = ('//code.jquery.com/jquery-2.1.1.min.js', '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js')
change_view(request, object_id, form_url='', extra_context=None)[source]
date_hierarchy = 'add_dttm'
fieldsets = [(None, {'fields': (('applicant', 'author'), ('category', 'urgent'), 'reason', ('req_sum', 'accepted_sum'), 'status', ('month_of_payment', 'payment_dt'), 'examination_comment', ('submitted_paper', 'paid_with_cash', 'verified'), 'vk_link')}), ('Изображения', {'fields': ('images_tags',), 'classes': ('collapse',)})]
form

alias of AidRequestAdminForm

get_applicant_name(obj)[source]
get_changelist(request, **kwargs)[source]
get_readonly_fields(request, obj=None)[source]

Can change applicant only if request is created by another person

inlines = [<class 'fin_aid.admin.AidDocumentInline'>]
list_display = ['get_applicant_name', 'add_dttm', 'category', 'req_sum', 'urgent', 'status', 'accepted_sum', 'payment_dt', 'submitted_paper']
list_editable = ['status', 'accepted_sum', 'payment_dt', 'submitted_paper']
list_filter = [<class 'fin_aid.admin.PaymentMonthFilter'>, 'status', 'category', 'urgent', 'submitted_paper', 'paid_with_cash', 'verified']
media
save_model(request, obj, form, change)[source]
search_fields = ['applicant__first_name', 'applicant__last_name', 'reason']
class fin_aid.admin.AidRequestChangeList(*args, **kwargs)[source]

Bases: django.contrib.admin.views.main.ChangeList

class fin_aid.admin.CategoryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('name', 'reason', 'max_sum', 'max_quantity', 'notifications')
media
class fin_aid.admin.MonthlyDataAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('year', 'month', 'limit', 'deadline_dt', 'student_deadline_dt', 'payment_dt')
media
class fin_aid.admin.PaymentMonthFilter(request, params, model, model_admin)[source]

Bases: django.contrib.admin.filters.SimpleListFilter

lookups(request, model_admin)[source]
parameter_name = 'payment_dt'
queryset(request, queryset)[source]
title = 'Месяц выплаты'
class fin_aid.admin.ScholarAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ['student', 'scholarship']
list_filter = ['scholarship']
media
class fin_aid.admin.ScholarshipAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ['name', 'sum', 'frequency']
list_filter = ['frequency']
media

fin_aid.create_paper module

fin_aid.create_paper.create_paper(aid_request: fin_aid.models.AidRequest)[source]
fin_aid.create_paper.get_sex(user: django.contrib.auth.models.User)[source]

fin_aid.forms module

class fin_aid.forms.AidRequestAdminForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

FOLLOWING = 3
MONTHS = [(1, 'Ближайший месяц'), (2, 'Следующий месяц'), (3, 'Через месяц')]
class Meta[source]

Bases: object

exclude = ['examination_dttm']
model

alias of AidRequest

widgets = {'author': <django_select2.forms.ModelSelect2Widget object>, 'applicant': <django_select2.forms.ModelSelect2Widget object>}
NEXT = 2
THIS = 1
base_fields = OrderedDict([('author', <django.forms.models.ModelChoiceField object>), ('applicant', <django.forms.models.ModelChoiceField object>), ('category', <django.forms.models.ModelChoiceField object>), ('reason', <django.forms.fields.CharField object>), ('req_sum', <django.forms.fields.FloatField object>), ('urgent', <django.forms.fields.BooleanField object>), ('accepted_sum', <django.forms.fields.FloatField object>), ('status', <django.forms.fields.TypedChoiceField object>), ('payment_dt', <django.forms.fields.DateField object>), ('examination_comment', <django.forms.fields.CharField object>), ('submitted_paper', <django.forms.fields.BooleanField object>), ('paid_with_cash', <django.forms.fields.BooleanField object>), ('verified', <django.forms.fields.BooleanField object>), ('month_of_payment', <django.forms.fields.ChoiceField object>)])
declared_fields = OrderedDict([('month_of_payment', <django.forms.fields.ChoiceField object>)])
media
class fin_aid.forms.AidRequestCreateForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ['category', 'reason', 'req_sum', 'urgent']
model

alias of AidRequest

base_fields = OrderedDict([('category', <django.forms.models.ModelChoiceField object>), ('reason', <django.forms.fields.CharField object>), ('req_sum', <django.forms.fields.FloatField object>), ('urgent', <django.forms.fields.BooleanField object>), ('document1', <django.forms.fields.FileField object>), ('document2', <django.forms.fields.FileField object>), ('document3', <django.forms.fields.FileField object>)])
declared_fields = OrderedDict([('document1', <django.forms.fields.FileField object>), ('document2', <django.forms.fields.FileField object>), ('document3', <django.forms.fields.FileField object>)])
media
class fin_aid.forms.SelectExportMonthForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.forms.Form

base_fields = OrderedDict([('year', <django.forms.fields.IntegerField object>), ('month', <django.forms.fields.ChoiceField object>)])
declared_fields = OrderedDict([('year', <django.forms.fields.IntegerField object>), ('month', <django.forms.fields.ChoiceField object>)])
media

fin_aid.models module

class fin_aid.models.AidDocument(id, file, request, is_application_paper, is_image)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

file

The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assigns a file object on assignment so you can do:

>>> with open('/path/to/hello.world', 'r') as f:
...     instance.file = File(f)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_application_paper

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_image

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
request

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

request_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class fin_aid.models.AidRequest(id, author, applicant, category, reason, req_sum, urgent, accepted_sum, status, add_dttm, examination_dttm, payment_dt, examination_comment, submitted_paper, paid_with_cash, verified)[source]

Bases: django.db.models.base.Model

ACCEPTED = 2
AID_REQUEST_STATUS = ((1, 'Заявление рассматривается'), (2, 'Заявление одобрено'), (3, 'В заявлении отказано'), (4, 'Необходимо уточнить данные'), (5, 'Предварительно одобрено'))
DECLINED = 3
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

INFO_NEEDED = 4
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

PRE_ACCEPTED = 5
WAITING = 1
accepted_sum

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

add_dttm

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

aiddocument_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

applicant

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

applicant_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

author

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

author_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

can_view(user)[source]
category

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

category_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

examination_comment

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

examination_dttm

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_absolute_url()[source]
get_next_by_add_dttm(*moreargs, **morekwargs)
get_previous_by_add_dttm(*moreargs, **morekwargs)
get_status_display(*moreargs, **morekwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

images_tags()[source]
objects = <django.db.models.manager.Manager object>
paid_with_cash

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

payment_dt

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

reason

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

req_sum

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

status

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

status_text
submitted_paper

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

static to_csv(filename, year=None, month=None)[source]
urgent

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod user_requests(user: django.contrib.auth.models.User)[source]
verified

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class fin_aid.models.Category(id, name, reason, max_sum, max_quantity, notifications, show_to_students, is_senate)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

aidrequest_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_senate

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_quantity

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_sum

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

notifications

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
reason

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

show_to_students

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class fin_aid.models.MonthlyData(id, year, month, limit, deadline_dt, student_deadline_dt, payment_dt)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

MONTH = [(1, 'Январь'), (2, 'Февраль'), (3, 'Март'), (4, 'Апрель'), (5, 'Май'), (6, 'Июнь'), (7, 'Июль'), (8, 'Август'), (9, 'Сентябрь'), (10, 'Октябрь'), (11, 'Ноябрь'), (12, 'Декабрь')]
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

classmethod current()[source]
deadline_dt

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_month_display(*moreargs, **morekwargs)
get_next_by_deadline_dt(*moreargs, **morekwargs)
get_next_by_payment_dt(*moreargs, **morekwargs)
get_next_by_student_deadline_dt(*moreargs, **morekwargs)
get_previous_by_deadline_dt(*moreargs, **morekwargs)
get_previous_by_payment_dt(*moreargs, **morekwargs)
get_previous_by_student_deadline_dt(*moreargs, **morekwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

limit

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

month

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod next()[source]
objects = <django.db.models.manager.Manager object>
payment_dt

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

student_deadline_dt

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sum_used
year

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class fin_aid.models.Scholar(id, student, scholarship)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
scholarship

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

scholarship_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

student

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

student_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class fin_aid.models.Scholarship(id, name, sum, frequency)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

MONTH = 1
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

PAYMENT_FREQUENCY = ((1, 'Раз в месяц'), (2, 'Раз в семестр'), (3, 'Раз в год'))
SEMESTER = 2
YEAR = 3
frequency

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_frequency_display(*moreargs, **morekwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
scholar_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

sum

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

fin_aid.models.document_path(instance, filename)[source]
fin_aid.models.get_name(self: django.contrib.auth.models.User)[source]
fin_aid.models.get_next_date(dt=None, t='payment')[source]
fin_aid.models.is_image(file)[source]
fin_aid.models.user_hash(user)[source]

fin_aid.tests module

fin_aid.urls module

fin_aid.views module

class fin_aid.views.AidRequestCreate(**kwargs)[source]

Bases: fin_aid.views.AidRequestCreateUpdate, django.views.generic.edit.BaseCreateView

get_success_message(cleaned_data)[source]
class fin_aid.views.AidRequestCreateUpdate(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.detail.SingleObjectTemplateResponseMixin, django.views.generic.base.TemplateResponseMixin, django.views.generic.edit.ModelFormMixin, django.views.generic.edit.FormMixin, django.views.generic.detail.SingleObjectMixin, django.views.generic.edit.ProcessFormView, django.views.generic.base.View

dispatch(request, *args, **kwargs)
form_class

alias of AidRequestCreateForm

form_valid(form)[source]
get_context_data(**kwargs)[source]
get_success_url()[source]
model

alias of AidRequest

template_name = 'fin_aid/aidrequest_form.html'
class fin_aid.views.AidRequestDelete(**kwargs)[source]

Bases: django.views.generic.edit.DeleteView

dispatch(request, *args, **kwargs)[source]
model

alias of AidRequest

success_url = '/aid/requests'
class fin_aid.views.AidRequestDetail(**kwargs)[source]

Bases: django.views.generic.detail.DetailView

dispatch(request, *args, **kwargs)[source]
model

alias of AidRequest

class fin_aid.views.AidRequestList(**kwargs)[source]

Bases: django.views.generic.list.ListView

dispatch(request, *args, **kwargs)
get_queryset()[source]
model

alias of AidRequest

class fin_aid.views.AidRequestUpdate(**kwargs)[source]

Bases: fin_aid.views.AidRequestCreateUpdate, django.views.generic.edit.BaseUpdateView

dispatch(request, *args, **kwargs)[source]
success_message = 'Заявление на матпомощь изменено. Результаты рассмотрения будут доступны в личном кабинете'
class fin_aid.views.ExportAidRequest(**kwargs)[source]

Bases: django.views.generic.edit.BaseFormView, django.views.generic.edit.FormMixin, django.views.generic.edit.ProcessFormView, django.views.generic.base.View

dispatch(request, *args, **kwargs)[source]
form_class

alias of SelectExportMonthForm

form_invalid(form)[source]
form_valid(form)[source]
success_url = '/admin/fin_aid/aidrequest/'

Module contents

notifications package

Provides functions for notifications sending and takes care of user’s preferences. You can use this functions to add notifications functionality to your app.

Subpackages

Submodules

notifications.notify module

Functions for dealing with messages.

They take care of different notification providers, user’s notifications settings, staff groups...

Currently only functions for vk.com are implemented, other are represented by skeletons

VK Api (v5.46) is actively used.

notifications.notify._notify_email(user: django.contrib.auth.models.User, text, title=None)[source]

Skeleton for internal function which sends email notifications

notifications.notify._notify_telegram(user: django.contrib.auth.models.User, text, title=None)[source]

Skeleton for internal function which sends telegram notifications

notifications.notify._notify_vk(user: django.contrib.auth.models.User, text, title=None)[source]

Private finction, sends vk notifications

notifications.notify.get_email(user: django.contrib.auth.models.User)[source]

Skeleton for function, retrieving user’s email for notifications

notifications.notify.get_telegram_uid(user: django.contrib.auth.models.User)[source]

Skeleton for function retrieving user’s telegram uid

notifications.notify.get_vk_uid(user: django.contrib.auth.models.User)[source]

Get user’s vk uid or None

If user logged not through vk, tries to find his vk profile in profiles.models.StudentInfo UID needed (formerly?) for sendind messages, displaying beautiful links in VK messages and, maybe, some other staff

Safe, as long as user is valid django.contrib.auth.models.User instance, no additional checks are needed.

notifications.notify.message_int_hash(text)[source]

Generate hash by message text. Different mesasages get different hashes

Used in vk api to prevent sending duplicate messages

notifications.notify.notify(user: django.contrib.auth.models.User, text, title=None)[source]

Main function for sending notifications.

Aggregates internal functions for managing different providers and, according to notifications.models.UserNotificationsSettings, sends messages.

“Safe and simple”: no checks on user are required, just pass user and proper text. You don’t have to worry if user has email of allowed messages from vk

notifications.notify.notify_group(group, text, title=None)[source]

Function for notifying whole department about some event.

Based on notifications.notify.notify(). You only have to provide group (name or Group instance) and message text.

Get code displaying html link to user’s profile.

If it’s impossible to find user’s vk, return user’s name without a link.

Safe, as long as user is valid django.contrib.auth.models.User instance, no additional checks are needed.

Get code displaying internal link to user’s profile for embedding into vk messages.

If it’s impossible to find user’s vk, return user’s name without a link.

Safe, as long as user is valid django.contrib.auth.models.User instance, no additional checks are needed.

notifications.notify.vk_messages_allowed(user)[source]

Returns True if user allowed vk notifications from our community or we can’t find user’s vk

Useg, eg, to remind user allow messages:)

notifications.models module

class notifications.models.Notification(*args, **kwargs)[source]

Bases: django.db.models.base.Model

All sent notifications

METHODS = [(1, 'e-mail'), (2, 'Вконтакте'), (3, 'telegram')]

List of all available notifications providers.

method

Notifications provider. Choices are stored in METHODS

result

Provider’s response to message sending attempt. VK returns message_id if success or error message when smth goes wrong

send_dttm

Added automatically

text

Notification text. No escaping & so on is provided!

user

OneToOne link to django.contrib.auth.models.User instance

class notifications.models.UserNotificationsSettings(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Model for storing user’s notifications preferences.

Currently profiles.views.change_subscribing_status() changes profiles.models.UserProfile, that triggers notifications.signals.user_create() signal, which updates UserNotificationsSettings.

allow_email

Boolean field

allow_telegram

Boolean field

allow_vk

Boolean field

last_allow_vk_reminder

Date & time of last reminder (message on site) to allow vk messages. Used by notifications.signals.allow_vk_messages()

Maybe such reminders should be stored in table like Notifications?

user

OneToOne link to django.contrib.auth.models.user instance

notifications.admin module

Super obvious admin module

notifications.app module

class notifications.app.NotificationsConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

Configuration class for notifications module

ready()[source]

Connect notifications.signals

notifications.signals module

Todo

Currently used to send notifications from apps like fin_aid and cycle_storage. It’ll be better

to move this functionality directly to that apps. Maybe create submodule notifications.py in every package?

notifications.signals.aidrequest_save_notify(sender, instance, created, **kwargs)[source]

Receives post_save signal from fin_aid.models.AidRequest.

Depending on new aid request status, sends notifictions to treasurers or users.

notifications.signals.bicycle_save_notify(sender, instance, created, **kwargs)[source]

Receives post_save signal from fin_aid.models.AidRequest.

Depending on new bicycle storage request status, sends notifictions to staff or users.

notifications.signals.remind_to_allow_messages(sender, request, **kwargs)[source]

After user logs in, displays reminder to allow vk notifications.

notifications.signals.user_create(sender, instance, created, **kwargs)[source]

Receives post_save signal from profiles.models.UserProfile.

Used to update/create notifications.models.UserNotificationsSettings when profiles.models.UserProfile is changes or created.

notifications.templates module

Functions generating text for notifications.

notifications.templates.bicycle_new_request(bicycle)[source]

Message notifying staff about new cycle storage request

notifications.templates.bicycle_request_status_change(bicycle)[source]

Message notifying user about examination of his bicycle storage request

notifications.templates.fin_aid_new_request(aid_request)[source]

Message notifying treasurers about new aid requests

notifications.templates.fin_aid_received(user)[source]

Skeleton for message notifying student about aid received this month. SHould be send at time when scholarship is received

notifications.templates.fin_aid_request_status_change(aid_request)[source]

Message notifying student about examination of fin_aid.models.AidRequest

notifications.templates.get_abs_url(loc_url)[source]

Get absolute (including domain name) url based on loc_url provided.

Should be moved to core app.

notifications.templates.poll_available(poll)[source]

Message notifying user about available poll

notifications.tests module

Module contents

polls package

Subpackages

polls.templatetags package

Submodules
polls.templatetags.polls_extras module
polls.templatetags.polls_extras.poll_panel(context, name)[source]
Module contents

Submodules

polls.admaking module

polls.admaking.create_advert(request, poll_id)[source]
polls.admaking.html_to_pdf(html_filename, pdf_filename)[source]
polls.admaking.make_html_advert(request, poll_id, poll_obj)[source]
polls.admaking.make_pdf(request, poll_id)[source]

polls.admin module

class polls.admin.ChoiceInline(parent_model, admin_site)[source]

Bases: nested_inline.admin.NestedTabularInline

exclude = ('votes',)
extra = 1
media
model

alias of Choice

class polls.admin.ParticipantAdmin(model, admin_site)[source]

Bases: nested_inline.admin.NestedModelAdmin

list_display = ['user_information', 'poll', 'voted']
list_editable = ['voted']
list_filter = ['voted', 'poll']
media
search_fields = ['user_information__fio']
class polls.admin.ParticipantInline(parent_model, admin_site)[source]

Bases: nested_inline.admin.NestedTabularInline

exclude = ('user_information',)
fields = ('voted',)
list_dispay = ['userprofile']
media
model

alias of Participant

ordering = ('user_information',)
class polls.admin.PollAdmin(model, admin_site)[source]

Bases: nested_inline.admin.NestedModelAdmin

audit_button(obj)[source]
exclude = ('voted_users', 'times_mailed', 'last_mailing')
inlines = [<class 'polls.admin.ParticipantInline'>, <class 'polls.admin.QuestionInline'>]
list_display = ['name', 'pdf_button', 'audit_button', 'mailing_button']
mailing_button(obj)[source]
media
pdf_button(obj)[source]
save_model(request, obj, form, change)[source]
class polls.admin.QuestionAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

inlines = [<class 'polls.admin.ChoiceInline'>]
media
models

alias of Question

class polls.admin.QuestionInline(parent_model, admin_site)[source]

Bases: nested_inline.admin.NestedTabularInline

extra = 1
inlines = [<class 'polls.admin.ChoiceInline'>]
media
model

alias of Question

polls.app module

class polls.app.PollsConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

name = 'polls'
ready()[source]
verbose_name = 'Голосовалка'

polls.forms module

class polls.forms.UserForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ('last_name', 'first_name')
model

alias of User

base_fields = OrderedDict([('last_name', <django.forms.fields.CharField object>), ('first_name', <django.forms.fields.CharField object>)])
declared_fields = OrderedDict()
media
class polls.forms.UserProfileForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: polls.forms.UserProfileFormReduced

class Meta[source]

Bases: polls.forms.Meta

fields = ('room', 'cardnumber')
base_fields = OrderedDict([('room', <django.forms.fields.CharField object>), ('cardnumber', <django.forms.fields.CharField object>)])
declared_fields = OrderedDict([('cardnumber', <django.forms.fields.CharField object>)])
media
class polls.forms.UserProfileFormReduced(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ('room',)
model

alias of UserProfile

base_fields = OrderedDict([('room', <django.forms.fields.CharField object>)])
declared_fields = OrderedDict()
media

polls.mailing module

polls.mailing.approve_mailing(request, poll_id)[source]
polls.mailing.is_staff(user)[source]
polls.mailing.mail_unvoted(request, poll_id)[source]

polls.models module

class polls.models.Choice(id, question, choice_text, votes, created)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

choice_text

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
question

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

question_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

save(*args, **kwargs)[source]
userhash_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

votes

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class polls.models.Participant(id, user_information, poll, voted)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
poll

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

poll_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user_information

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

user_information_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

voted

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class polls.models.Poll(id, name, begin_date, end_date, target_room, target_group, target_course, public, times_mailed, last_mailing, poll_type, only_for_staff)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

POLL_TYPE = (('WITHOUT_TARGET_LIST', 'WITHOUT TARGET LIST'), ('TARGET_LIST', 'TARGET LIST'))
TARGET_LIST = 'TARGET_LIST'
WITHOUT_TARGET_LIST = 'WITHOUT_TARGET_LIST'
begin_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

create_target_list_from_group_room_course(group=None, room=None, course=None, only_staff=False)[source]
end_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_begin_date(*moreargs, **morekwargs)
get_next_by_end_date(*moreargs, **morekwargs)
get_poll_type_display(*moreargs, **morekwargs)
get_previous_by_begin_date(*moreargs, **morekwargs)
get_previous_by_end_date(*moreargs, **morekwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_closed()[source]
is_started()[source]
is_user_target(user)[source]
is_user_voted(user)[source]
last_mailing

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
only_for_staff

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

participant_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

poll_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

public

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

question_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

target_course

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

target_group

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

target_room

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

times_mailed

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

voted_users

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

pizza.toppings and topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class polls.models.Question(id, poll, question, answer_type, choices_order, required)[source]

Bases: django.db.models.base.Model

ANSWER_TYPE_CHOICES = (('ONE', 'Выбор одного варианта'), ('MANY', 'Выбор нескольких вариантов'), ('OWN', 'Свой вариант'))
CREATION = 'created'
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

MANY = 'MANY'
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ONE = 'ONE'
ORDER_TYPES = (('created', 'В порядке добавления'), ('?', 'В случайном порядке'))
OWN = 'OWN'
RANDOM = '?'
answer_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

choice_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

choices_order

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_answer_type_display(*moreargs, **morekwargs)
get_choices_order_display(*moreargs, **morekwargs)
get_ordered_choices()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
poll

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

poll_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

question

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

required

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class polls.models.UserHash(id, value, choice, user)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

choice

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

choice_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

user_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

polls.signals module

polls.signals.remind_to_vote(sender, request, **kwargs)[source]

polls.tests module

class polls.tests.PollTestCase(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_vote_answer_type_MANY()[source]
test_vote_answer_type_ONE()[source]

polls.urls module

polls.views module

class polls.views.Available(**kwargs)[source]

Bases: polls.views.IndexBase

get_context_data(*args, **kwargs)[source]
get_queryset()[source]
class polls.views.Closed(**kwargs)[source]

Bases: polls.views.IndexBase

get_context_data(*args, **kwargs)[source]
get_queryset()[source]
class polls.views.Detail(**kwargs)[source]

Bases: django.views.generic.detail.DetailView

get_context_data(**kwargs)[source]
model

alias of Poll

template_name = 'polls/detail.html'
class polls.views.Index(**kwargs)[source]

Bases: polls.views.Closed, polls.views.Available

get_context_data(*args, **kwargs)[source]
get_queryset()[source]
class polls.views.IndexBase(**kwargs)[source]

Bases: django.views.generic.list.ListView

context_object_name = 'poll_list'
paginate_by = 10
template_name = 'polls/index.html'
class polls.views.Results(**kwargs)[source]

Bases: django.views.generic.detail.DetailView

get_queryset()[source]
model

alias of Poll

template_name = 'polls/results.html'
class polls.views.Voted(**kwargs)[source]

Bases: polls.views.IndexBase

get_context_data(*args, **kwargs)[source]
get_queryset()[source]
polls.views.detailed(request, poll_id)[source]
polls.views.done(request)[source]
polls.views.is_staff(user)[source]
polls.views.make_csv(p, filename)[source]
polls.views.make_win_csv(oldfilename, filename)[source]
polls.views.vote(request, poll_id)[source]
polls.views.voters(request, poll_id)[source]

Module contents

profiles package

  • Handling OAuth-2 authorization and user authentication.
  • Verification of students.

User can log in (and sign up) through one of the available OAuth providers (VK, Google). For each social auth a new user (instance of django.contrib.auth.models.User) is created. This process is handled by core.settings.SOCIAL_AUTH_PIPELINE. For each new user an profiles.models.UserProfile is created (See profiles.signals).

profiles.models.StudentInfo stores info about all DGAP students (received from administration). If system can associate logged user with DGAP student (profiles.psa.approve_student()), then link to UserProfile is created.

Each student have only one StudentInfo but can have multile User (one for each OAuth provider)

Todo

Refactoring in auth system needed. Now multiple accounts of singe student are linked through User -> UserProfile -> StudentInfo. Super stupid.

profiles.models module

class profiles.models.StudentInfo(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Model for storing info about students. Created from administration database. If user is verificated as enrolled student (by vk profile or corporate email), StudentInfo is linked with UserProfile. See profiles.psa.approve_student().

course

Course. Valid for students in gap year

fio

Student’s full name

first_name

Student’s first name

group

Academic group. If data is taken from settlement database (like in 2017), for students in gap year group number is outdated. Must be taken into account when managing elections.

last_name

Student’s last name

phystech

Student’s corporate email - name.surname@phystech.edu. Used for student’s verification

room

Student’s room. Currently unused, but who knows?

sex

Student’s sex. Currently used to obtain genitive case of user’s name when creating official papers.

See fin_aid.create_paper

static upload_csv(filename='~/spiski.csv')[source]

Populate database from csv with student’s data. CSV can be obtained, for example, from settlement database. :param str filename: file name (including path) of csv file with student’s data

vk

Link to student’s vk.com profile. It is quite challenging to obtain links for all students, but during last two elections electoral commission did it so we only have to collect accounts of freshmen yearly, which is much easier.

This field includes https:// prefix and contains screen name, not id!

https://vk.com/smnnk, not vk.com/smmnk or https://vk.com/id28749823.

class profiles.models.UserProfile(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Helper model, created after each new user registration.

Formerly stored essential data about user, now only links to StudentInfo

dorm

Super old, lol

group

Not used now

is_approved

True if user is approved ad DGAP student. Variable is set in profiles.psa.approve_student()

is_subscribed

Currently notifications are moved to standalone app notifications, so this setting should migrate to notification.models.UserNotificationsSettings, because different nitification services are available (vk, email, telegram).

middlename

Not used now

room

Not used now

student_info

Link to StudentInfo

user

Link to user

profiles.models.is_same_student(student1: django.contrib.auth.models.User, student2: django.contrib.auth.models.User)[source]

Returns True if student1 and student2 are linked to the same StudentInfo (= they belong to one person)

profiles.models.is_same_student_or_admin(student1: django.contrib.auth.models.User, student2: django.contrib.auth.models.User, group_name)[source]

Checks if student1 is the same student as student2 or student1 is admin with appropriate access rights.

Returns True if both student1 and student2 are linked to the same StudentInfo or student1 has specific group or student1 is superuser. Can be useful when checkng access/update permissions: student may create object from one social account and then login from another.

profiles.models.same_users_list(user: django.contrib.auth.models.User)[source]

Get list of all users, associated with given user’s StudentInfo.

Logins through different OAuth providers create multiple User objects for one student. This function allows us to get list of all User objects, belonging to the same student. It must be taken into account when working with user-related objects.

Let’s imagine fragment of dispatch method in UpdateView

Correct usage:

if author not in same_users_list(user):
    raise PermissionDenied

Incorrect usage:

if author != user:
    raise PermissionDenied

profiles.admin module

Admin classes for models in profiles.models.

Quite obvious, only custom admin for django.contrib.auth.models.User may raise some interest. See source code.

profiles.psa module

class profiles.psa.MiptOAuth2(strategy=None, *args, **kwargs)[source]

Bases: social_core.backends.oauth.BaseOAuth2

MIPT OAuth authentication backend. Not used currently

class profiles.psa.SocialAuthExceptionMiddlewareExtended(get_response=None)[source]

Bases: social_django.middleware.SocialAuthExceptionMiddleware

Exception wich raised after authentification error. Describing message is provided

Currently handled errors: AuthForbidden: users can login only with google accounta at @phystech.edu. See core.settings.SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS AuthAlreadyAssociated: you can associate your social account with only on user.

profiles.psa.approve_student(backend, user, response, *args, **kwargs)[source]

Tries to verify user as enrolled student.

  • If backend is google-oauth2, then user.email should be student’s corporate email
  • If backend is vk-oauth-2, then user.username is vk profile’s screen name

Function is invoked as part of core.settings.SOCIAL_AUTH_PIPELINE. user.email & so on are populated after social login also in that pipeline

profiles.psa.set_middlename(backend, user, response, *args, **kwargs)[source]

Legacy social auth middleware to set middlename. Currently middlename is stored in profiles.models.StudentInfo

profiles.app module

class profiles.app.ProfilesConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

Configuration class for profiles module

ready()[source]

Connect profiles.signals

profiles.signals module

profiles.signals.create_user_profile(sender, instance, created, **kwargs)[source]

Receives post_save signal from User. Creates profiles.models.Userprofile for new users

profiles.signals.update_student_info(sender, instance, created, **kwargs)[source]

Receives post_save signal from profiles.models.StudentInfo. Updates linked profiles.models.UserProfile

As UserProfile is no longer used to store ersonal data, this function is unnecessary.

profiles.tests module

profiles.urls module

URL dispatcher for module profiles.

profiles.views module

Currently uses only one template - profiles/profile.html

class profiles.views.UserChangeEmail(**kwargs)[source]

Bases: django.views.generic.edit.UpdateView

Legacy function for changing user email. Currently not used

model

alias of User

profiles.views.change_subscribing_status(request)[source]

Subscribe/unsubscrube from notifications.

request.user.userprofile.is_subscribed = not request.user.userprofile.is_subscribed

profiles.views.profile_view(request)[source]

Super old and super shitty view displaying info about current user. Looks like a bit of refactoring needed.

  • Adds error messages if user is not approved & so on.
  • Sets context variables with user’s social services logins
  • Renders template profiles/profile.html

Module contents

senate package

Subpackages

Submodules

senate.admin module

class senate.admin.CategoryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ['name', 'department']
list_filter = ['department']
media
class senate.admin.DepartmentAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ['name', 'group', 'head']
media
readonly_fields = ['members']
class senate.admin.EmployeeAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ['person', 'department', 'position', 'phone', 'public', 'importance']
list_editable = ['public', 'importance']
list_filter = ['department', 'public']
media
search_fields = ['person__first_name', 'person__last_name']
class senate.admin.EventInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.StackedInline

can_delete = True
media
model

alias of Event

readonly_fields = ['images_tags']
class senate.admin.IssueAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

inlines = [<class 'senate.admin.EventInline'>]
list_display = ['category', 'name', 'author', 'status', 'add_dttm', 'last_event', 'want_to_help', 'assigned_dept']
list_filter = ['category', 'status', 'want_to_help', 'assigned_dept']
media

senate.app module

class senate.app.SenateConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

name = 'senate'
ready()[source]
verbose_name = 'Сенат'

senate.forms module

class senate.forms.DeptEventCreateForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ['cls', 'info', 'new_status', 'new_dept']
model

alias of Event

widgets = {'info': <class 'django.forms.widgets.Textarea'>}
base_fields = OrderedDict([('cls', <django.forms.fields.TypedChoiceField object>), ('info', <django.forms.fields.CharField object>), ('new_status', <django.forms.fields.TypedChoiceField object>), ('new_dept', <django.forms.models.ModelChoiceField object>), ('photo1', <django.forms.fields.ImageField object>), ('photo2', <django.forms.fields.ImageField object>), ('photo3', <django.forms.fields.ImageField object>)])
declared_fields = OrderedDict([('photo1', <django.forms.fields.ImageField object>), ('photo2', <django.forms.fields.ImageField object>), ('photo3', <django.forms.fields.ImageField object>)])
media
class senate.forms.IssueCreateForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ['name', 'category', 'want_to_help']
model

alias of Issue

base_fields = OrderedDict([('name', <django.forms.fields.CharField object>), ('category', <django.forms.models.ModelChoiceField object>), ('want_to_help', <django.forms.fields.BooleanField object>), ('issue_descr', <django.forms.fields.CharField object>), ('photo1', <django.forms.fields.ImageField object>), ('photo2', <django.forms.fields.ImageField object>), ('photo3', <django.forms.fields.ImageField object>)])
declared_fields = OrderedDict([('issue_descr', <django.forms.fields.CharField object>), ('photo1', <django.forms.fields.ImageField object>), ('photo2', <django.forms.fields.ImageField object>), ('photo3', <django.forms.fields.ImageField object>)])
media
class senate.forms.UserEventCreateForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ['info']
model

alias of Event

widgets = {'info': <class 'django.forms.widgets.Textarea'>}
base_fields = OrderedDict([('info', <django.forms.fields.CharField object>), ('photo1', <django.forms.fields.ImageField object>), ('photo2', <django.forms.fields.ImageField object>), ('photo3', <django.forms.fields.ImageField object>)])
declared_fields = OrderedDict([('photo1', <django.forms.fields.ImageField object>), ('photo2', <django.forms.fields.ImageField object>), ('photo3', <django.forms.fields.ImageField object>)])
media

senate.models module

class senate.models.Category(id, name, department, public)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

department

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

department_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

issue_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
public

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class senate.models.Department(id, group, name, head)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

add_member(user)[source]
employee_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

group

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

restaurant.place is a ForwardOneToOneDescriptor instance.

group_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

head

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

head_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

members
name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class senate.models.Employee(id, person, position, department, public, phone, importance)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

department

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

department_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

importance

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
person

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

person_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

phone

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

position

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

public

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class senate.models.Event(id, issue, author, add_dttm, cls, info, new_dept, new_worker, new_status)[source]

Bases: django.db.models.base.Model

ASSIGNEE_CHANGE = 2
CLASS = ((1, 'Обновление'), (2, 'Смена ответственного'), (3, 'Изменение статуса'), (4, 'Запрос сведений'), (5, 'Создание обращения'))
DETAILS_REQUEST = 4
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

MAX_INFO_LEN = 2048
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

OPEN = 5
STATUS_CHANGE = 3
UPDATE = 1
add_dttm

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

author

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

author_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

cls

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

eventdocument_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_cls_display(*moreargs, **morekwargs)
get_new_status_display(*moreargs, **morekwargs)
get_next_by_add_dttm(*moreargs, **morekwargs)
get_previous_by_add_dttm(*moreargs, **morekwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

images_tags()[source]
info

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

issue

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

issue_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

new_dept

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

new_dept_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

new_status

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

new_worker

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

new_worker_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class senate.models.EventDocument(id, file, event)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

event

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

event_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

file

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class senate.models.Issue(id, author, category, name, status, add_dttm, last_event, close_dttm, want_to_help, assigned_dept, assigned_worker)[source]

Bases: django.db.models.base.Model

ACCEPTED = 3
CLOSED = 2
DECLINED = 4
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

OPEN = 1
STATUS = ((1, 'Открыто'), (2, 'Закрыто'), (3, 'Инициатива одобрена'), (4, 'Инициатива отклонена'))
add_dttm

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

assigned_dept

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

assigned_dept_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

assigned_worker

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

assigned_worker_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

author

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

author_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

category

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

category_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

close_dttm

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

event_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_absolute_url()[source]
get_next_by_add_dttm(*moreargs, **morekwargs)
get_previous_by_add_dttm(*moreargs, **morekwargs)
get_status_display(*moreargs, **morekwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_event

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
status

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

want_to_help

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

senate.signals module

senate.signals.employee_create(sender, instance: senate.models.Employee, created, **kwargs)[source]
senate.signals.event_save(sender, instance: senate.models.Event, created, **kwargs)[source]
senate.signals.issue_update_text(event: senate.models.Event)[source]
senate.signals.new_issue_text(issue: senate.models.Issue)[source]

senate.tests module

senate.urls module

senate.views module

class senate.views.DeptIssueList(**kwargs)[source]

Bases: django.contrib.auth.mixins.UserPassesTestMixin, django.views.generic.list.ListView

dispatch(request, *args, **kwargs)
get_queryset()[source]
model

alias of Issue

template_name = 'senate/issue_list.html'
test_func()[source]
class senate.views.EmployeeList(**kwargs)[source]

Bases: django.views.generic.list.ListView

model

alias of Employee

ordering = ['-importance', 'department', 'position']
class senate.views.FullIssueList(**kwargs)[source]

Bases: django.views.generic.list.ListView

get_queryset()[source]
model

alias of Issue

template_name = 'senate/issue_list.html'
class senate.views.IssueCreate(**kwargs)[source]

Bases: django.views.generic.edit.CreateView

dispatch(request, *args, **kwargs)
form_class

alias of IssueCreateForm

form_valid(form)[source]
get_initial()[source]
get_success_url()[source]
model

alias of Issue

class senate.views.IssueDetail(**kwargs)[source]

Bases: django.views.generic.base.View

get(request, *args, **kwargs)[source]
post(request, *args, **kwargs)[source]
class senate.views.IssueDisplay(**kwargs)[source]

Bases: django.views.generic.detail.DetailView

dispatch(request, *args, **kwargs)
get_context_data(**kwargs)[source]
model

alias of Issue

class senate.views.MyIssueList(**kwargs)[source]

Bases: django.views.generic.list.ListView

dispatch(request, *args, **kwargs)
get_queryset()[source]
model

alias of Issue

template_name = 'senate/issue_list.html'
class senate.views.UserEventCreate(**kwargs)[source]

Bases: django.views.generic.detail.SingleObjectMixin, django.views.generic.edit.FormView

dispatch(request, *args, **kwargs)
form_valid(form)[source]
get_form_class()[source]
get_success_url()[source]
model

alias of Issue

post(request, *args, **kwargs)[source]
template_name = 'senate/issue_detail.html'

Module contents

servertime package

App that helps to display server date, time and timezone. Currently results of app’s work are displayed (via ajax queries) near site logo in navigation menu.

Subpackages

Submodules

servertime.tests module

servertime.urls module

Available URLs: * servertime/ - returns server time * serverdate/ - returns server date * servertimezone - returns server timezone

Module contents