This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# Static files (CSS, JavaScript, Images) | |
# https://docs.djangoproject.com/en/1.10/howto/static-files/ | |
STATICFILES_DIRS = ( | |
os.path.join(BASE_DIR, 'static'), | |
) | |
STATIC_URL = '/static/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# Logging settings | |
LOGGING = { | |
'disable_existing_loggers': False, | |
'formatters': { | |
'verbose': { | |
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s", | |
'datefmt' : "%d-%m-%Y %H:%M:%S" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class ArticleAttachment(models.Model): | |
""" | |
Attached files for articles | |
""" | |
att_file = models.FileField( | |
upload_to='content/uploads/articles/%Y/%m/%d/%H/%M/%S') | |
class Meta: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
severity_level = models.ForeignKey( | |
'business.SeverityLevel', null=True, blank=True, | |
on_delete=models.SET( | |
None | |
) | |
) | |
status = models.ForeignKey( | |
'CaseStatus', null=True, blank=True, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.mail import send_mail | |
... | |
send_mail( | |
NEW_CASE_EMAIL_SUBJECT.format(case.title), | |
NEW_CASE_EMAIL_MESSAGE.format( | |
case.title, | |
case.description, | |
case.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Custom tag library to test group membership. | |
""" | |
from django import template | |
from django.contrib.auth.models import Group | |
from apps.contacts.models import Contact | |
register = template.Library() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class ArticleAddForm(ModelForm): | |
""" | |
Form for creating a new article. | |
""" | |
content = forms.CharField(widget=forms.Textarea(attrs={'class': 'content_textarea'})) | |
project = forms.ModelChoiceField(queryset=Project.objects.all(), required=False) | |
class Meta: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticleUpdateForm(ModelForm): | |
""" | |
Form for updating an article. | |
""" | |
def __init__(self, *args, **kwargs): | |
super(ArticleUpdateForm, self).__init__(*args, **kwargs) | |
self.fields['attachments'] = forms.ModelMultipleChoiceField( | |
queryset=self.instance.attachments.all(), required=False | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.fields['watchers'] = forms.ModelMultipleChoiceField( | |
queryset=User.objects.filter( | |
Q(contact__organization=self.request.user.contact.organization)| | |
Q(contact__organization__org_type__in=['Owner',])| | |
Q(groups__name__in=['issues_admin', 'cases_admin']) | |
).distinct().order_by('username') | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In the __init__ method: | |
self.fields['description'].help_text = mark_safe(FIELD_REQUIRED_MSG) | |
self.fields['issue_type'].help_text = mark_safe(FIELD_REQUIRED_MSG) | |
self.fields['priority'].help_text = mark_safe(FIELD_REQUIRED_MSG) | |
self.fields['project'].help_text = mark_safe(FIELD_REQUIRED_MSG) | |
self.fields['title'].help_text = mark_safe(FIELD_REQUIRED_MSG) | |
# and in class Meta: |