# Path: djwechat/portfolio/models.py
# class Banner(models.Model):
#     ''' Banner '''
#     title = models.CharField(verbose_name=_('Title'),
#                              max_length=15,
#                              null=True, blank=True)
#     link = models.URLField(verbose_name=_('Link'),
#                            null=True, blank=True)
#     image = models.CharField(verbose_name=_('Image'),
#                              max_length=200,
#                              help_text=_('The banner image url or data uri'),
#                              null=True, blank=True)
#     description = models.TextField(verbose_name=_('Description'),
#                                    null=True, blank=True)
#     order = models.SmallIntegerField(verbose_name=_('Order'),
#                                      default=0,
#                                      help_text=_('The order of the banner'))
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         db_table = 'portfolio_banner'
#         verbose_name = _('Banner')
#         verbose_name_plural = _('Banners')
# 
# Path: djwechat/portfolio/models.py
# class Experience(models.Model):
#     ''' 时间节点，用于绘制时间轴timeline '''
#     user = models.ForeignKey(verbose_name=_('User'), to=User)
#     start = models.DateField(verbose_name=_('Start'))  # 经历开始时间
#     end = models.DateField(verbose_name=_('End'),
#                            null=True, blank=True)  # 结束时间
#     title = models.CharField(verbose_name=_('Title'), max_length=15)  # 标题
#     description = models.TextField(verbose_name=_('Description'))  # 具体内容
#     image = models.URLField(verbose_name=_('ImageURL'),
#                             null=True, blank=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         db_table = 'portfolio_milestone'
#         verbose_name = _('Experience')
#         verbose_name_plural = _('Experience')
# 
# Path: djwechat/portfolio/models.py
# class Skill(models.Model):
#     ''' 技能，用于绘制技能评估表（技能雷达radar）'''
#     user = models.ForeignKey(verbose_name=_('User'), to=User)
#     name = models.CharField(verbose_name=_('Name'), max_length=15)  # 技能名
#     level = models.PositiveSmallIntegerField(
#         verbose_name=_('Level(0-100)'))  # 等级
#     period = models.SmallIntegerField(verbose_name=_('Period(months)'))  # 使用时长
#     description = models.TextField(verbose_name=_('Description'))  # 具体描述
# 
#     def __str__(self):
#         return '%s(%d)' % (self.name, self.level)
# 
#     class Meta:
#         db_table = 'portfolio_skill'
#         verbose_name = _('Skill')
#         verbose_name_plural = _('Skills')
# 
# Path: djwechat/portfolio/models.py
# class User(models.Model):
#     ''' 个人主页 '''
#     name = models.CharField(verbose_name=_('Name'),
#                             max_length=25)
#     email = models.EmailField(verbose_name=_('Email'),
#                               null=True, blank=True)
#     phone = models.CharField(verbose_name=_('Phone'),
#                              max_length=15,
#                              null=True, blank=True)
#     nickname = models.CharField(verbose_name=_('Nick Name'),
#                                 max_length=25,
#                                 null=True, blank=True)
#     country = models.CharField(verbose_name=_('Country'),
#                                max_length=15,
#                                null=True, blank=True)
#     province = models.CharField(verbose_name=_('Province'),
#                                 max_length=15,
#                                 null=True, blank=True)
#     city = models.CharField(verbose_name=_('City'),
#                             max_length=15,
#                             null=True, blank=True)
#     address = models.CharField(verbose_name=_('Address'),
#                                max_length=50,
#                                null=True, blank=True)
#     description = models.TextField(verbose_name=_('Description'),
#                                    null=True, blank=True)  # 备注
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         db_table = 'portfolio_user'
#         verbose_name = _('User')
#         verbose_name_plural = _('Users')


from django.shortcuts import get_object_or_404
from django.shortcuts import render
from .models import Banner
from .models import Experience
from .models import Skill
from .models import User
# -*- coding: utf-8 -*-
# Create your views here.


def home(request, uid=1):
    user = get_object_or_404(User, pk=uid)
    template = 'portfolio/index.html'
    context = {'banners': Banner.objects.all().order_by('order', 'id'),
               'title': user.name,

# Path: djwechat/portfolio/models.py
# class Banner(models.Model):
#     ''' Banner '''
#     title = models.CharField(verbose_name=_('Title'),
#                              max_length=15,
#                              null=True, blank=True)
#     link = models.URLField(verbose_name=_('Link'),
#                            null=True, blank=True)
#     image = models.CharField(verbose_name=_('Image'),
#                              max_length=200,
#                              help_text=_('The banner image url or data uri'),
#                              null=True, blank=True)
#     description = models.TextField(verbose_name=_('Description'),
#                                    null=True, blank=True)
#     order = models.SmallIntegerField(verbose_name=_('Order'),
#                                      default=0,
#                                      help_text=_('The order of the banner'))
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         db_table = 'portfolio_banner'
#         verbose_name = _('Banner')
#         verbose_name_plural = _('Banners')
# 
# Path: djwechat/portfolio/models.py
# class Experience(models.Model):
#     ''' 时间节点，用于绘制时间轴timeline '''
#     user = models.ForeignKey(verbose_name=_('User'), to=User)
#     start = models.DateField(verbose_name=_('Start'))  # 经历开始时间
#     end = models.DateField(verbose_name=_('End'),
#                            null=True, blank=True)  # 结束时间
#     title = models.CharField(verbose_name=_('Title'), max_length=15)  # 标题
#     description = models.TextField(verbose_name=_('Description'))  # 具体内容
#     image = models.URLField(verbose_name=_('ImageURL'),
#                             null=True, blank=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         db_table = 'portfolio_milestone'
#         verbose_name = _('Experience')
#         verbose_name_plural = _('Experience')
# 
# Path: djwechat/portfolio/models.py
# class Skill(models.Model):
#     ''' 技能，用于绘制技能评估表（技能雷达radar）'''
#     user = models.ForeignKey(verbose_name=_('User'), to=User)
#     name = models.CharField(verbose_name=_('Name'), max_length=15)  # 技能名
#     level = models.PositiveSmallIntegerField(
#         verbose_name=_('Level(0-100)'))  # 等级
#     period = models.SmallIntegerField(verbose_name=_('Period(months)'))  # 使用时长
#     description = models.TextField(verbose_name=_('Description'))  # 具体描述
# 
#     def __str__(self):
#         return '%s(%d)' % (self.name, self.level)
# 
#     class Meta:
#         db_table = 'portfolio_skill'
#         verbose_name = _('Skill')
#         verbose_name_plural = _('Skills')
# 
# Path: djwechat/portfolio/models.py
# class User(models.Model):
#     ''' 个人主页 '''
#     name = models.CharField(verbose_name=_('Name'),
#                             max_length=25)
#     email = models.EmailField(verbose_name=_('Email'),
#                               null=True, blank=True)
#     phone = models.CharField(verbose_name=_('Phone'),
#                              max_length=15,
#                              null=True, blank=True)
#     nickname = models.CharField(verbose_name=_('Nick Name'),
#                                 max_length=25,
#                                 null=True, blank=True)
#     country = models.CharField(verbose_name=_('Country'),
#                                max_length=15,
#                                null=True, blank=True)
#     province = models.CharField(verbose_name=_('Province'),
#                                 max_length=15,
#                                 null=True, blank=True)
#     city = models.CharField(verbose_name=_('City'),
#                             max_length=15,
#                             null=True, blank=True)
#     address = models.CharField(verbose_name=_('Address'),
#                                max_length=50,
#                                null=True, blank=True)
#     description = models.TextField(verbose_name=_('Description'),
#                                    null=True, blank=True)  # 备注
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         db_table = 'portfolio_user'
#         verbose_name = _('User')
#         verbose_name_plural = _('Users')


# Path: djwechat/portfolio/views.py
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from .models import Banner
from .models import Experience
from .models import Skill
from .models import User

# -*- coding: utf-8 -*-
# Create your views here.


def home(request, uid=1):
    user = get_object_or_404(User, pk=uid)
    template = 'portfolio/index.html'
    context = {'banners': Banner.objects.all().order_by('order', 'id'),
               'title': user.name,

               'experience': Experience.objects.filter(user=user).order_by('start', 'id'),