Commit fbcf5253 authored by Skia's avatar Skia

Merge branch 'pep8' into 'master'

Pep8

See merge request !81
parents 753fe0d1 9447de44
Pipeline #1075 failed with stage
in 3 minutes and 19 seconds
......@@ -35,5 +35,3 @@ admin.site.register(SimplifiedAccountingType)
admin.site.register(Operation)
admin.site.register(Label)
admin.site.register(Company)
......@@ -25,7 +25,6 @@
from django.core.urlresolvers import reverse
from django.core.exceptions import ValidationError
from django.core import validators
from django.db.models import Count
from django.db import models
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
......@@ -37,6 +36,7 @@ from decimal import Decimal
from core.models import User, SithFile
from club.models import Club
class CurrencyField(models.DecimalField):
"""
This is a custom database field used for currency
......@@ -50,12 +50,13 @@ class CurrencyField(models.DecimalField):
def to_python(self, value):
try:
return super(CurrencyField, self).to_python(value).quantize(Decimal("0.01"))
return super(CurrencyField, self).to_python(value).quantize(Decimal("0.01"))
except AttributeError:
return None
return None
# Accounting classes
class Company(models.Model):
name = models.CharField(_('name'), max_length=60)
street = models.CharField(_('street'), max_length=60, blank=True)
......@@ -104,6 +105,7 @@ class Company(models.Model):
def __str__(self):
return self.name
class BankAccount(models.Model):
name = models.CharField(_('name'), max_length=30)
iban = models.CharField(_('iban'), max_length=255, blank=True)
......@@ -131,6 +133,7 @@ class BankAccount(models.Model):
def __str__(self):
return self.name
class ClubAccount(models.Model):
name = models.CharField(_('name'), max_length=30)
club = models.ForeignKey(Club, related_name="club_account", verbose_name=_("club"))
......@@ -244,6 +247,7 @@ class GeneralJournal(models.Model):
self.amount -= o.amount
self.save()
class Operation(models.Model):
"""
An operation is a line in the journal, a debit or a credit
......@@ -258,17 +262,17 @@ class Operation(models.Model):
invoice = models.ForeignKey(SithFile, related_name='operations', verbose_name=_("invoice"), null=True, blank=True)
done = models.BooleanField(_('is done'), default=False)
simpleaccounting_type = models.ForeignKey('SimplifiedAccountingType', related_name="operations",
verbose_name=_("simple type"), null=True, blank=True)
verbose_name=_("simple type"), null=True, blank=True)
accounting_type = models.ForeignKey('AccountingType', related_name="operations",
verbose_name=_("accounting type"), null=True, blank=True)
verbose_name=_("accounting type"), null=True, blank=True)
label = models.ForeignKey('Label', related_name="operations",
verbose_name=_("label"), null=True, blank=True, on_delete=models.SET_NULL)
verbose_name=_("label"), null=True, blank=True, on_delete=models.SET_NULL)
target_type = models.CharField(_('target type'), max_length=10,
choices=[('USER', _('User')), ('CLUB', _('Club')), ('ACCOUNT', _('Account')), ('COMPANY', _('Company')), ('OTHER', _('Other'))])
choices=[('USER', _('User')), ('CLUB', _('Club')), ('ACCOUNT', _('Account')), ('COMPANY', _('Company')), ('OTHER', _('Other'))])
target_id = models.IntegerField(_('target id'), null=True, blank=True)
target_label = models.CharField(_('target label'), max_length=32, default="", blank=True)
linked_operation = models.OneToOneField('self', related_name='operation_linked_to', verbose_name=_("linked operation"),
null=True, blank=True, default=None)
null=True, blank=True, default=None)
class Meta:
unique_together = ('number', 'journal')
......@@ -349,8 +353,9 @@ class Operation(models.Model):
def __str__(self):
return "%d € | %s | %s | %s" % (
self.amount, self.date, self.accounting_type, self.done,
)
self.amount, self.date, self.accounting_type, self.done,
)
class AccountingType(models.Model):
"""
......@@ -359,13 +364,13 @@ class AccountingType(models.Model):
Thoses are numbers used in accounting to classify operations
"""
code = models.CharField(_('code'), max_length=16,
validators=[
validators.RegexValidator(r'^[0-9]*$', _('An accounting type code contains only numbers')),
],
)
validators=[
validators.RegexValidator(r'^[0-9]*$', _('An accounting type code contains only numbers')),
],
)
label = models.CharField(_('label'), max_length=128)
movement_type = models.CharField(_('movement type'), choices=[('CREDIT', _('Credit')), ('DEBIT', _('Debit')),
('NEUTRAL', _('Neutral'))], max_length=12)
('NEUTRAL', _('Neutral'))], max_length=12)
class Meta:
verbose_name = _("accounting type")
......@@ -383,7 +388,8 @@ class AccountingType(models.Model):
return reverse('accounting:type_list')
def __str__(self):
return self.code+" - "+self.get_movement_type_display()+" - "+self.label
return self.code + " - " + self.get_movement_type_display() + " - " + self.label
class SimplifiedAccountingType(models.Model):
"""
......@@ -391,7 +397,7 @@ class SimplifiedAccountingType(models.Model):
"""
label = models.CharField(_('label'), max_length=128)
accounting_type = models.ForeignKey(AccountingType, related_name="simplified_types",
verbose_name=_("simplified accounting types"))
verbose_name=_("simplified accounting types"))
class Meta:
verbose_name = _("simplified type")
......@@ -408,7 +414,8 @@ class SimplifiedAccountingType(models.Model):
return reverse('accounting:simple_type_list')
def __str__(self):
return self.get_movement_type_display()+" - "+self.accounting_type.code+" - "+self.label
return self.get_movement_type_display() + " - " + self.accounting_type.code + " - " + self.label
class Label(models.Model):
"""Label allow a club to sort its operations"""
......@@ -432,4 +439,3 @@ class Label(models.Model):
def can_be_viewed_by(self, user):
return self.club_account.can_be_viewed_by(user)
This diff is collapsed.
......@@ -22,7 +22,7 @@
#
#
from django.conf.urls import url, include
from django.conf.urls import url
from accounting.views import *
......@@ -71,5 +71,3 @@ urlpatterns = [
# User account
url(r'^refound/account$', RefoundAccountView.as_view(), name='refound_account'),
]
This diff is collapsed.
......@@ -29,4 +29,3 @@ from club.models import Club, Membership
admin.site.register(Club)
admin.site.register(Membership)
......@@ -27,12 +27,13 @@ from django.core import validators
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ValidationError
from django.db import IntegrityError, transaction
from django.db import transaction
from django.core.urlresolvers import reverse
from django.utils import timezone
from core.models import User, MetaGroup, Group, SithFile
# Create your models here.
class Club(models.Model):
......@@ -43,17 +44,17 @@ class Club(models.Model):
name = models.CharField(_('name'), max_length=64)
parent = models.ForeignKey('Club', related_name='children', null=True, blank=True)
unix_name = models.CharField(_('unix name'), max_length=30, unique=True,
validators=[
validators.RegexValidator(
r'^[a-z0-9][a-z0-9._-]*[a-z0-9]$',
_('Enter a valid unix name. This value may contain only '
'letters, numbers ./-/_ characters.')
),
],
error_messages={
'unique': _("A club with that unix name already exists."),
},
)
validators=[
validators.RegexValidator(
r'^[a-z0-9][a-z0-9._-]*[a-z0-9]$',
_('Enter a valid unix name. This value may contain only '
'letters, numbers ./-/_ characters.')
),
],
error_messages={
'unique': _("A club with that unix name already exists."),
},
)
address = models.CharField(_('address'), max_length=254)
# email = models.EmailField(_('email address'), unique=True) # This should, and will be generated automatically
owner_group = models.ForeignKey(Group, related_name="owned_club",
......@@ -61,7 +62,7 @@ class Club(models.Model):
edit_groups = models.ManyToManyField(Group, related_name="editable_club", blank=True)
view_groups = models.ManyToManyField(Group, related_name="viewable_club", blank=True)
home = models.OneToOneField(SithFile, related_name='home_of_club', verbose_name=_("home"), null=True, blank=True,
on_delete=models.SET_NULL)
on_delete=models.SET_NULL)
class Meta:
ordering = ['name', 'unix_name']
......@@ -109,9 +110,9 @@ class Club(models.Model):
self._change_unixname(self.unix_name)
super(Club, self).save(*args, **kwargs)
if creation:
board = MetaGroup(name=self.unix_name+settings.SITH_BOARD_SUFFIX)
board = MetaGroup(name=self.unix_name + settings.SITH_BOARD_SUFFIX)
board.save()
member = MetaGroup(name=self.unix_name+settings.SITH_MEMBER_SUFFIX)
member = MetaGroup(name=self.unix_name + settings.SITH_MEMBER_SUFFIX)
member.save()
subscribers = Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first()
self.make_home()
......@@ -153,6 +154,7 @@ class Club(models.Model):
return sub.is_subscribed
_memberships = {}
def get_membership_for(self, user):
"""
Returns the current membership the given user
......@@ -168,6 +170,7 @@ class Club(models.Model):
Club._memberships[self.id][user.id] = m
return m
class Membership(models.Model):
"""
The Membership class makes the connection between User and Clubs
......@@ -184,7 +187,7 @@ class Membership(models.Model):
start_date = models.DateField(_('start date'), default=timezone.now)
end_date = models.DateField(_('end date'), null=True, blank=True)
role = models.IntegerField(_('role'), choices=sorted(settings.SITH_CLUB_ROLES.items()),
default=sorted(settings.SITH_CLUB_ROLES.items())[0][0])
default=sorted(settings.SITH_CLUB_ROLES.items())[0][0])
description = models.CharField(_('description'), max_length=128, null=False, blank=True)
def clean(self):
......@@ -195,9 +198,9 @@ class Membership(models.Model):
raise ValidationError(_('User is already member of that club'))
def __str__(self):
return self.club.name+' - '+self.user.username+' - '+str(settings.SITH_CLUB_ROLES[self.role])+str(
" - "+str(_('past member')) if self.end_date is not None else ""
)
return self.club.name + ' - ' + self.user.username + ' - ' + str(settings.SITH_CLUB_ROLES[self.role]) + str(
" - " + str(_('past member')) if self.end_date is not None else ""
)
def is_owned_by(self, user):
"""
......@@ -216,4 +219,3 @@ class Membership(models.Model):
def get_absolute_url(self):
return reverse('club:club_members', kwargs={'club_id': self.club.id})
......@@ -31,6 +31,7 @@ from club.models import Club
# Create your tests here.
class ClubTest(TestCase):
def setUp(self):
call_command("populate")
......@@ -41,34 +42,34 @@ class ClubTest(TestCase):
def test_create_add_user_to_club_from_root_ok(self):
self.client.login(username='root', password='plop')
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.skia.id,
"start_date": "12/06/2016",
"role": 3})
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
response = self.client.get(reverse("club:club_members", kwargs={"club_id": self.bdf.id}))
self.assertTrue(response.status_code == 200)
self.assertTrue("S&#39; Kia</a></td>\\n <td>Responsable info</td>" in str(response.content))
def test_create_add_user_to_club_from_root_fail_not_subscriber(self):
self.client.login(username='root', password='plop')
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
response = self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.guy.id,
"start_date": "12/06/2016",
"role": 3})
self.assertTrue(response.status_code == 200)
self.assertTrue('<ul class="errorlist nonfield"><li>' in str(response.content))
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
response = self.client.get(reverse("club:club_members", kwargs={"club_id": self.bdf.id}))
self.assertFalse("Guy Carlier</a></td>\\n <td>Responsable info</td>" in str(response.content))
def test_create_add_user_to_club_from_root_fail_already_in_club(self):
self.client.login(username='root', password='plop')
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.skia.id,
"start_date": "12/06/2016",
"role": 3})
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
response = self.client.get(reverse("club:club_members", kwargs={"club_id": self.bdf.id}))
self.assertTrue("S&#39; Kia</a></td>\\n <td>Responsable info</td>" in str(response.content))
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
response = self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.skia.id,
"start_date": "12/06/2016",
"role": 4})
......@@ -77,30 +78,29 @@ class ClubTest(TestCase):
def test_create_add_user_to_club_from_skia_ok(self):
self.client.login(username='root', password='plop')
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.skia.id,
"start_date": "12/06/2016",
"role": 10})
self.client.login(username='skia', password='plop')
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.rbatsbak.id,
"start_date": "12/06/2016",
"role": 9})
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
response = self.client.get(reverse("club:club_members", kwargs={"club_id": self.bdf.id}))
self.assertTrue(response.status_code == 200)
self.assertTrue("""Richard Batsbak</a></td>\\n <td>Vice-Pr\\xc3\\xa9sident</td>""" in str(response.content))
def test_create_add_user_to_club_from_richard_fail(self):
self.client.login(username='root', password='plop')
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.rbatsbak.id,
"start_date": "12/06/2016",
"role": 3})
self.client.login(username='rbatsbak', password='plop')
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {
response = self.client.post(reverse("club:club_members", kwargs={"club_id": self.bdf.id}), {
"user": self.skia.id,
"start_date": "12/06/2016",
"role": 10})
self.assertTrue(response.status_code == 200)
self.assertTrue("<li>Vous n&#39;avez pas la permission de faire cela</li>" in str(response.content))
......@@ -22,7 +22,7 @@
#
#
from django.conf.urls import url, include
from django.conf.urls import url
from club.views import *
......@@ -40,4 +40,3 @@ urlpatterns = [
url(r'^(?P<club_id>[0-9]+)/tools$', ClubToolsView.as_view(), name='tools'),
url(r'^membership/(?P<membership_id>[0-9]+)/set_old$', MembershipSetOldView.as_view(), name='membership_set_old'),
]
This diff is collapsed.
......@@ -30,5 +30,3 @@ admin.site.register(Sith)
admin.site.register(News)
admin.site.register(Weekmail)
......@@ -25,15 +25,14 @@
from django.shortcuts import render
from django.db import models, transaction
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse_lazy, reverse
from django.core.urlresolvers import reverse
from django.conf import settings
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.core.mail import EmailMultiAlternatives
from django.core.exceptions import ValidationError
from core.models import User, Preferences
from club.models import Club
import os
class Sith(models.Model):
"""A one instance class storing all the modifiable infos"""
......@@ -48,12 +47,14 @@ class Sith(models.Model):
def __str__(self):
return "⛩ Sith ⛩"
NEWS_TYPES = [
('NOTICE', _('Notice')),
('EVENT', _('Event')),
('WEEKLY', _('Weekly')),
('CALL', _('Call')),
]
('NOTICE', _('Notice')),
('EVENT', _('Event')),
('WEEKLY', _('Weekly')),
('CALL', _('Call')),
]
class News(models.Model):
"""The news class"""
......@@ -81,6 +82,7 @@ class News(models.Model):
def __str__(self):
return "%s: %s" % (self.type, self.title)
class NewsDate(models.Model):
"""
A date class, useful for weekly events, or for events that just have no date
......@@ -95,6 +97,7 @@ class NewsDate(models.Model):
def __str__(self):
return "%s: %s - %s" % (self.news.title, self.start_date, self.end_date)
class Weekmail(models.Model):
"""
The weekmail class
......@@ -113,12 +116,12 @@ class Weekmail(models.Model):
dest = [i[0] for i in Preferences.objects.filter(receive_weekmail=True).values_list('user__email')]
with transaction.atomic():
email = EmailMultiAlternatives(
subject=self.title,
body=self.render_text(),
from_email=settings.SITH_COM_EMAIL,
to=Sith.objects.first().weekmail_destinations.split(' '),
bcc=dest,
)
subject=self.title,
body=self.render_text(),
from_email=settings.SITH_COM_EMAIL,
to=Sith.objects.first().weekmail_destinations.split(' '),
bcc=dest,
)
email.attach_alternative(self.render_html(), "text/html")
email.send()
self.sent = True
......@@ -128,12 +131,12 @@ class Weekmail(models.Model):
def render_text(self):
return render(None, "com/weekmail_renderer_text.jinja", context={
'weekmail': self,
}).content.decode('utf-8')
}).content.decode('utf-8')
def render_html(self):
return render(None, "com/weekmail_renderer_html.jinja", context={
'weekmail': self,
}).content.decode('utf-8')
}).content.decode('utf-8')
def get_banner(self):
return "http://" + settings.SITH_URL + static("com/img/weekmail_banner.png")
......@@ -144,6 +147,7 @@ class Weekmail(models.Model):
def is_owned_by(self, user):
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
class WeekmailArticle(models.Model):
weekmail = models.ForeignKey(Weekmail, related_name="articles", verbose_name=_("weekmail"), null=True)
title = models.CharField(_("title"), max_length=64)
......
......@@ -28,7 +28,7 @@ from django.core.urlresolvers import reverse
from django.core.management import call_command
from core.models import User, RealGroup
from com.models import Sith
class ComTest(TestCase):
def setUp(self):
......@@ -56,4 +56,3 @@ class ComTest(TestCase):
r = self.client.get(reverse("core:index"))
self.assertTrue(r.status_code == 200)
self.assertTrue("""<div id="info_box">\\n <div class="markdown"><h3>INFO: <strong>Caaaataaaapuuuulte!!!!</strong></h3>""" in str(r.content))
......@@ -22,7 +22,7 @@
#
#
from django.conf.urls import url, include
from django.conf.urls import url
from com.views import *
......
This diff is collapsed.
......@@ -33,8 +33,9 @@ admin.site.unregister(AuthGroup)
admin.site.register(RealGroup)
admin.site.register(Page)
@admin.register(SithFile)
class SithFileAdmin(admin.ModelAdmin):
form = make_ajax_form(SithFile, {
'parent': 'files', # ManyToManyField
})
})
......@@ -23,9 +23,9 @@
#
from django.apps import AppConfig
from django.dispatch import receiver
from django.core.signals import request_started
class SithConfig(AppConfig):
name = 'core'
verbose_name = "Core app of the Sith"
......@@ -48,4 +48,3 @@ class SithConfig(AppConfig):
request_started.connect(clear_cached_groups, weak=False, dispatch_uid="clear_cached_groups")
request_started.connect(clear_cached_memberships, weak=False, dispatch_uid="clear_cached_memberships")
# TODO: there may be a need to add more cache clearing
......@@ -31,16 +31,19 @@ from club.models import Club
from counter.models import Product, Counter
from accounting.models import ClubAccount, Company
def check_token(request):
return ('counter_token' in request.session.keys() and
request.session['counter_token'] and
Counter.objects.filter(token=request.session['counter_token']).exists())
request.session['counter_token'] and
Counter.objects.filter(token=request.session['counter_token']).exists())
class RightManagedLookupChannel(LookupChannel):
def check_auth(self, request):
if not request.user.was_subscribed and not check_token(request):
raise PermissionDenied
@register('users')
class UsersLookup(RightManagedLookupChannel):
model = User
......@@ -54,6 +57,7 @@ class UsersLookup(RightManagedLookupChannel):
def format_item_display(self, item):
return item.get_display_name()
@register('groups')
class GroupsLookup(RightManagedLookupChannel):
model = Group
......@@ -67,6 +71,7 @@ class GroupsLookup(RightManagedLookupChannel):
def format_item_display(self, item):
return item.name
@register('clubs')
class ClubLookup(RightManagedLookupChannel):
model = Club
......@@ -80,6 +85,7 @@ class ClubLookup(RightManagedLookupChannel):
def format_item_display(self, item):
return item.name
@register('counters')
class CountersLookup(RightManagedLookupChannel):
model = Counter
......@@ -90,6 +96,7 @@ class CountersLookup(RightManagedLookupChannel):
def format_item_display(self, item):
return item.name
@register('products')
class ProductsLookup(RightManagedLookupChannel):
model = Product
......@@ -101,6 +108,7 @@ class ProductsLookup(RightManagedLookupChannel):
def format_item_display(self, item):
return "%s (%s)" % (item.name, item.code)
@register('files')
class SithFileLookup(RightManagedLookupChannel):
model = SithFile
......@@ -108,6 +116,7 @@ class SithFileLookup(RightManagedLookupChannel):
def get_query(self, q, request):
return self.model.objects.filter(name__icontains=q)[:50]
@register('club_accounts')
class ClubAccountLookup(RightManagedLookupChannel):
model = ClubAccount
......@@ -118,6 +127,7 @@ class ClubAccountLookup(RightManagedLookupChannel):
def format_item_display(self, item):
return item.name
@register('companies')
class CompaniesLookup(RightManagedLookupChannel):
model = Company
......
......@@ -21,4 +21,3 @@
# Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
......@@ -44,7 +44,6 @@ class Command(BaseCommand):
args['precision'] = settings.SASS_PRECISION
return sass.compile(**args)
def is_compilable(self, file, ext_list):
path, ext = os.path.splitext(file)
return ext in ext_list
......
This diff is collapsed.
......@@ -23,9 +23,8 @@
#
import os
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from django.core.management import call_command
from django.conf import settings
class Command(BaseCommand):
......@@ -37,7 +36,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
root_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
try:
os.mkdir(os.path.join(root_path)+'/data')
os.mkdir(os.path.join(root_path) + '/data')
print("Data dir created")
except Exception as e:
repr(e)
......
......@@ -24,7 +24,7 @@
import re
from mistune import Renderer, InlineGrammar, InlineLexer, Markdown, escape, escape_link
from django.core.urlresolvers import reverse_lazy, reverse
from django.core.urlresolvers import reverse
class SithRenderer(Renderer):
......@@ -54,13 +54,16 @@ class SithRenderer(Renderer):
src = original_src
else:
width = m.group(1)
if not width.endswith('%'): width += "px"
if not width.endswith('%'):
width += "px"
style = "width: %s; " % width
try:
height = m.group(3)
if not height.endswith('%'): height += "px"
if not height.endswith('%'):
height += "px"
style += "height: %s; " % height
except: pass
except:
pass
else:
params = None
src = original_src
......@@ -77,6 +80,7 @@ class SithRenderer(Renderer):
return '%s />' % html
return '%s>' % html
class SithInlineGrammar(InlineGrammar):
double_emphasis = re.compile(
r'^\*{2}([\s\S]+?)\*{2}(?!\*)' # **word**
......@@ -94,6 +98,7 @@ class SithInlineGrammar(InlineGrammar):
r'^<sub>([\s\S]+?)</sub>' # <sub>text</sub>
)
class SithInlineLexer(InlineLexer):
grammar_class = SithInlineGrammar
......@@ -159,15 +164,16 @@ class SithInlineLexer(InlineLexer):
return self.renderer.emphasis(text)
def _process_link(self, m, link, title=None):
try: # Add page:// support for links
try: # Add page:// support for links
page = re.compile(
r'^page://(\S*)' # page://nom_de_ma_page
)
match = page.search(link)
page = match.group(1) or ""
link = reverse('core:page', kwargs={'page_name': page})
except: pass
try: # Add file:// support for links
except:
pass
try: # Add file:// support for links
file_link = re.compile(
r'^file://(\d*)/?(\S*)?' # file://4000/download
)
......@@ -175,9 +181,11 @@ class SithInlineLexer(InlineLexer):
id = match.group(1)
suffix = match.group(2) or ""
link = reverse('core:file_detail', kwargs={'file_id': id}) + suffix
except: pass
except: