Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python multiline method and TagBar #467

Closed
dmitry-saritasa opened this issue Dec 23, 2017 · 3 comments
Closed

Python multiline method and TagBar #467

dmitry-saritasa opened this issue Dec 23, 2017 · 3 comments

Comments

@dmitry-saritasa
Copy link

from django.contrib.auth.models import AbstractUser
from django.contrib.postgres.fields import HStoreField
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _

from author.decorators import with_author
from django_extensions.db.models import TimeStampedModel
from django_fsm import FSMField
from imagekit import models as imagekitmodels
from imagekit.processors import ResizeToFill
from phonenumber_field.modelfields import PhoneNumberField
from timezone_field import TimeZoneField

from libs import utils

# Solution to avoid unique_together for email
AbstractUser._meta.get_field('email')._unique = True


def upload_user_media_to(instance, filename):
    """Upload media files to this folder"""
    return '{}/{}/{}'.format(
        instance.__class__.__name__.lower(), instance.id,
        utils.get_random_filename(filename))


__all__ = [
    'Employee']


@with_author
class Employee(AbstractUser, TimeStampedModel):
    """Custom user model.

    Attributes:
        department (Department): What department the employee is in
        avatar (file): user's avatar, cropeed to fill 300x300 px
        notifications (dict): settings for notifications to user
        first_name (str): first name
        last_name (str): last name
        email (str): email (should be unique), this is our username field
        is_staff (bool): designates whether the user can log into
            this admin site
        is_active (bool): designates whether this user should be
            treated as active
        date_joined (datetime): when user joined
    """

    HIRED = 'H'
    ACTIVE = 'A'
    SICK = 'S'
    VACATION = 'V'
    PTO = 'P'
    FIRED = 'F'

    STATUSES = (
        (HIRED, 'hired'),
        (ACTIVE, 'active'),
        (SICK, 'sick'),
        (VACATION, 'vacation'),
        (PTO, 'pto'),
        (FIRED, 'fired'),
    )

    status = FSMField(
        default=HIRED,
        choices=STATUSES,
        protected=True)

    branch = models.ForeignKey(
        'company.Branch',
        null=True,
        related_name='employees',
        editable=True)

    department = models.ForeignKey(
        'company.Department',
        help_text='What department the employee is in',
        null=True,
        related_name='employees',
        editable=True)

    worktype = models.ForeignKey(
        'company.Worktype',
        null=True,
        related_name='employees',
        editable=True)

    recruiter = models.ForeignKey(
        'Employee',
        null=True,
        related_name='recruits',
        editable=True)

    # direct supervisor of the employee
    supervisor = models.ForeignKey(
        'Employee',
        null=True,
        related_name='supervisees',
        editable=True)

    # other people interested in this employee
    # activities
    followers = models.ManyToManyField(
        'self',
        related_name='following')

    username_ldap = models.CharField(
        max_length=255,
        null=True)

    is_utilized = models.BooleanField(
        default=True)

    is_contractor = models.BooleanField(
        default=False)

    is_daily_report_required = models.BooleanField(
        default=True)

    utilization = models.IntegerField(
        default=100,
        validators=[
            MinValueValidator(0),
            MaxValueValidator(100)])

    avatar = imagekitmodels.ProcessedImageField(
        upload_to=upload_user_media_to,
        processors=[ResizeToFill(300, 300)],
        format='PNG',
        options={'quality': 100},
        editable=True,
        null=True,
        blank=False)

    date_start = models.DateTimeField(
        _('date started'),
        null=True,
        default=timezone.now)

    address = models.CharField(
        max_length=255,
        blank=True)

    city = models.CharField(
        max_length=255,
        blank=True)

    state = models.CharField(
        max_length=50,
        blank=True)

    zip_code = models.CharField(
        max_length=20,
        blank=True)

    phone_number = PhoneNumberField(
        blank=True)

    cell_number = PhoneNumberField(
        blank=True)

    skype = models.CharField(
        max_length=255,
        blank=True)

    linkedin = models.CharField(
        max_length=255,
        blank=True)

    twitter = models.CharField(
        max_length=255,
        blank=True)

    instagram = models.CharField(
        max_length=255,
        blank=True)

    facebook = models.CharField(
        max_length=255,
        blank=True)

    website = models.CharField(
        max_length=255,
        blank=True)

    timezone = TimeZoneField()

    birthdate = models.DateField(
        null=True)

    is_birthdate_hidden = models.BooleanField(
        default=False)

    comment = models.TextField(
        blank=True)

    bucket_default_job = models.CharField(
        max_length=255,
        blank=True)

    notifications = HStoreField(
        null=True)

    # so authentication happens by email instead of username
    # and username becomes sort of nick
    USERNAME_FIELD = 'email'

    # Make sure to exclude email from required fields if authentication
    # is done by email
    REQUIRED_FIELDS = ['username']

    def __str__(self):
        return self.username

    class Meta:
        verbose_name = 'Employee'
        verbose_name_plural = 'Employees'

the code displayed like this:

image

Question

Any ideas how to remove blank, default etc...?

@marojenka
Copy link

marojenka commented Jan 22, 2018

@dmitry-saritasa this problem was mention before.
It's a problem with ctags, you might fix it by switching to https://github.com/universal-ctags/ctags.

@marojenka
Copy link

I faced this in one more system and for some reason putting universal-ctags as ctags in PATH wasn't enough: I had to explicitly set let g:tagbar_ctags_bin to a universal-ctags binary.

And it solved multi line problem.

@alerque
Copy link
Member

alerque commented Dec 3, 2019

The issue of getting meaningful tags in the first place should be solved by using Universal Ctags as mentioned above.

The issue of detection order on some systems is outlined a bit in #519 and the solution will be tracked there.

I'm closing this as there doesn't seem to be anything else actionable. If for some reason uctags doesn't do it for you let us know.

@alerque alerque closed this as completed Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants