Exemple #1
0
def update_user_info(request):
    user_id = request.POST.get('id')
    first_name = request.POST.get('first_name')
    last_name = request.POST.get('last_name')
    email = request.POST.get('email')
    img = request.POST.get('img')
    address = request.POST.get('address')
    interests = request.POST.get('interests')
    phone = request.POST.get('phone')
    birthday = request.POST.get('birthday')
    file_obj = request.FILES.get('file')
    if file_obj:
        print(
            '获取到的参数是:user_id,first_name,last_name,file_obj.name,request.user.img',
            user_id, first_name, last_name, email, file_obj.name,
            request.user.img)
        if '/static/img/upload_files/' + file_obj.name != request.user.img:
            print('获取到的图片和数据库中保存的不一样:file_obj.name:', file_obj.name)
            img_save = ImageStorage()
            file_name = img_save.save(file_obj.name, file_obj)
            img = '/static/img/upload_files/' + file_name

    User.objects.filter(id=user_id).update(first_name=first_name,
                                           phone=phone,
                                           birthday=birthday,
                                           interests=interests,
                                           address=address,
                                           last_name=last_name,
                                           email=email,
                                           img=img)
    return HttpResponseRedirect('/')
Exemple #2
0
class Activity(models.Model):
    objects = OrganizationManager()
    aName = models.CharField(max_length=20)
    createTime = models.DateTimeField(auto_now_add=True)
    updateTime = models.DateTimeField(auto_now=True)
    beginTime = models.DateTimeField()
    charge_man = models.CharField(max_length=20)
    phone_num = models.CharField(max_length=20)
    introduction = models.CharField(max_length=200)
    detail = models.TextField()
    img = models.ImageField(max_length=50,
                            upload_to='static/media/%Y%m',
                            storage=ImageStorage(),
                            default=None)
    organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
    place = models.CharField(max_length=20)
    type = models.CharField(max_length=20)
    isDelete = models.BooleanField(default=False)
    follow_num = models.IntegerField(default=0)
    participate_num = models.IntegerField(default=0)
    u = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    file = models.FileField(max_length=50,
                            upload_to='static/file/%Y%m',
                            storage=ImageStorage(),
                            default=None)

    class Meta:
        db_table = 'activity'
Exemple #3
0
class BigImage(models.Model):

    bigimg1 = models.ImageField(upload_to='index/bigimg1',
                                storage=ImageStorage(),
                                verbose_name='图片1')
    bigimg2 = models.ImageField(upload_to='index/bigimg2',
                                storage=ImageStorage(),
                                verbose_name='图片2')
    bigimg3 = models.ImageField(upload_to='index/bigimg3',
                                storage=ImageStorage(),
                                verbose_name='图片3')

    class Meta:
        verbose_name = '封面大图'
        verbose_name_plural = '封面大图'
Exemple #4
0
class Space(models.Model):
    id = models.AutoField(primary_key=True, verbose_name='场地主键')
    s_name = models.CharField(max_length=200, verbose_name='场地名字')
    s_image = models.ImageField(upload_to='static/img/space/%Y%m', storage=ImageStorage(), default='default_s.jpg',
                                verbose_name='场地图片')
    s_detail = models.TextField(verbose_name='场地简介')
    s_sale_num = models.IntegerField(default=0, verbose_name='场地热度')
Exemple #5
0
class Version(models.Model):
    version_id = models.AutoField(primary_key=True)
    is_newest = models.BooleanField(default=True)
    upload_time = models.DateTimeField(auto_now_add=True)
    picture = models.ForeignKey('Picture',
                                to_field='picture_id',
                                on_delete=models.CASCADE)
    original_picture = models.ImageField(upload_to='original',
                                         storage=ImageStorage())
    watermark_picture = models.ImageField(upload_to='watermark',
                                          storage=ImageStorage())
    digital_picture = models.ImageField(upload_to='digitalmark',
                                        storage=ImageStorage())

    def __str__(self):
        return self.picture.title + str(self.version_id)
Exemple #6
0
class SchoolImg(models.Model):
	school = models.ForeignKey(School,on_delete = models.CASCADE)
	school_pic = models.ImageField('图片',upload_to = './image/',storage = ImageStorage())

	class Meta:
		verbose_name = '学校图片'
		verbose_name_plural = '学校图片'
Exemple #7
0
class Content_Image(models.Model):
    Cid = models.AutoField(primary_key=True)
    # 这里的upload_to是指定图片存储的文件夹名称,上传文件之后会自动创建
    Cimage = models.ImageField(upload_to='img', storage=ImageStorage())
    Timestamp = models.CharField(max_length=20)

    def __str__(self):
        return str(self.Cid)
class user(models.Model):
    headImg = models.ImageField(
        upload_to='research/object_detection/test_images/',
        storage=ImageStorage())
    username = models.CharField(max_length=100)

    def __str__(self):
        return self.headImg
Exemple #9
0
class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)

    hometown = models.CharField(verbose_name=u"家乡", max_length=20, blank=True)
    address = models.CharField(verbose_name=u"现住", max_length=20, blank=True)
    occupation = models.CharField(verbose_name=u"职业",
                                  max_length=20,
                                  blank=True)
    hobby = models.CharField(verbose_name=u"爱好", max_length=100, blank=True)

    nickname = models.CharField(verbose_name=u"昵称",
                                max_length=10,
                                blank=True,
                                default="未名")

    GENDER_CHOICES = (
        (u'M', u'男'),
        (u'F', u'女'),
        (u'S', u'保密'),
    )
    gender = models.CharField(verbose_name=u"性别",
                              max_length=2,
                              choices=GENDER_CHOICES,
                              default='S')
    motto = models.CharField(verbose_name=u"座右铭",
                             max_length=30,
                             blank=True,
                             default="色即是空,空即是色")
    introduce = models.TextField(verbose_name=u"个人简介",
                                 max_length=200,
                                 blank=True)
    phone = models.CharField(verbose_name=u"手机", max_length=20, blank=True)
    image = models.ImageField(verbose_name=u"头像",
                              upload_to="image/user_img",
                              blank=True,
                              storage=ImageStorage())
    bgimg = models.ImageField(verbose_name=u"背景",
                              upload_to="image/bg_img",
                              blank=True,
                              storage=ImageStorage())

    def __unicode__(self):
        return self.user.username
class PhotoGallery(models.Model):
    img = models.ImageField(upload_to="CLSMats",
                            storage=ImageStorage(),
                            verbose_name=u"图片")
    url = models.URLField(max_length=500, verbose_name=u"商品链接")
    desc = models.TextField(verbose_name=u"图片描述")
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")

    class Meta:
        verbose_name = u"图片库"
        verbose_name_plural = verbose_name
Exemple #11
0
class PictureRecord(models.Model):
    user = models.ForeignKey(User, related_name="pictures")
    picture = models.ImageField(verbose_name=u"图片",
                                upload_to="article_image",
                                blank=True,
                                storage=ImageStorage())
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.picture.url
class QueryHistory(models.Model):
    img = models.ImageField(upload_to='upload',
                            storage=ImageStorage(),
                            verbose_name=u"图片")
    ip_addr = models.GenericIPAddressField(_('action ip'),
                                           blank=True,
                                           null=True)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u"查询时间")

    class Meta:
        verbose_name = u"查询历史"
        verbose_name_plural = verbose_name
Exemple #13
0
class t_attach_info(models.Model):
    # 文件名称
    image_name = models.CharField(max_length=500)
    # 文件路径
    image_url = models.ImageField(upload_to='img/%Y/%m',
                                  storage=ImageStorage())
    # 事件id
    event_id = models.CharField(max_length=50)
    # 创建时间
    create_time = models.DateTimeField(auto_now_add=True)
    # 更新时间
    update_time = models.DateTimeField(auto_now=True)
Exemple #14
0
class Goods(models.Model):
    name = models.CharField(max_length=20)
    status = models.CharField(max_length=2, default='')
    create_time = models.DateTimeField(default=timezone.now)
    goodsType_id = models.ForeignKey(GoodsType,
                                     related_name='goods_goods_type_id',
                                     on_delete=models.CASCADE)
    img = models.ImageField(upload_to='img', default='')
    single_price = models.DecimalField(decimal_places=2, max_digits=10)
    img = models.ImageField(
        upload_to='img/%Y/%m/%d',
        storage=ImageStorage())  # 如果上传文件可以将ImageField换为FileField
Exemple #15
0
class Bridal_Veil(models.Model):
    id = models.AutoField(primary_key=True, verbose_name='婚纱主键')
    bv_name = models.CharField(max_length=200, verbose_name='婚纱名')
    bv_num_all = models.IntegerField(default=10, verbose_name='总数量')
    bv_num_now = models.IntegerField(default=10, verbose_name='可用数量')
    bv_image = models.ImageField(upload_to='static/img/bridalVeil/%Y%m', storage=ImageStorage(),
                                 default='default_bv.jpg', verbose_name='婚纱照片')
    bv_detail = models.TextField(verbose_name='婚纱简介')
    bv_price = models.IntegerField(default=1000, verbose_name='婚纱价格')
    bv_photoNumMax = models.IntegerField(default=50, verbose_name='拍摄照片总张数')
    bv_photoNumMin = models.IntegerField(default=10, verbose_name='可选择张数')
    bv_sale_num = models.IntegerField(default=0, verbose_name='婚纱热度')
Exemple #16
0
class GraphicRecordModels(models.Model):
    """
    图文的博客
    """
    graphic_id = models.AutoField(primary_key=True)
    graphic_title = models.CharField(max_length=150, verbose_name='标题')
    graphic_body = RichTextUploadingField(config_name='default',
                                          verbose_name='内容')
    graphic_state = models.IntegerField(default=1, verbose_name='状态')
    graphic_learn = models.ForeignKey(LearnTypeModels,
                                      default=1,
                                      on_delete=models.DO_NOTHING,
                                      verbose_name='分类')
    graphic_views = models.PositiveIntegerField(default=0, verbose_name='阅读量')
    graphic_cover = models.ImageField(upload_to='images/%Y/%m/%d',
                                      storage=ImageStorage(),
                                      max_length=255,
                                      verbose_name='封面')
    graphic_about = models.CharField(max_length=100, verbose_name='简介')
    graphic_author = models.ForeignKey(AuthorModels,
                                       default=1,
                                       on_delete=models.DO_NOTHING,
                                       verbose_name='作者')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    """
    这个方法用来处理后台显示,当state状态为1时显示正常,否则显示异常
    category_colored_status.short_description 用来处理这个方法的标题显示
    """
    def category_colored_status(self):
        if self.graphic_state == 1:
            color_code = 'green'
            state_name = '正常'
        else:
            color_code = 'red'
            state_name = '异常'
        return format_html(
            '<span style="color: {};">{}</span>',
            color_code,
            state_name,
        )

    category_colored_status.short_description = '状态'

    def __str__(self):
        return self.graphic_title

    class Meta:
        db_table = 'graphic'
        verbose_name = '图文'
        verbose_name_plural = verbose_name
Exemple #17
0
class User(models.Model):
    UserID = models.AutoField(primary_key = True)
    Username = models.CharField(max_length = 20)
    Password = models.CharField(max_length = 20)

    Gender = models.CharField(max_length = 10, default = 'male')
    Region = models.CharField(max_length = 20, default = 'earth')
    Nickname = models.CharField(max_length = 20, default = 'fresh')
    # Avatar = models.CharField(max_length = 100)
    Avatar = models.ImageField(upload_to = 'avatar', storage = ImageStorage(), default = 'avatar/default.png') 
    Description = models.CharField(max_length = 40)

    def __str__(self):
        return self.Username
Exemple #18
0
class Cameraman(models.Model):
    id = models.AutoField(primary_key=True, verbose_name='摄影师主键')
    ca_name = models.CharField(max_length=200, verbose_name='账号')
    ca_nickName = models.CharField(max_length=200, verbose_name='昵称')
    ca_pwd = models.CharField(max_length=50, verbose_name='密码')
    ca_detail = models.TextField(verbose_name='简介')
    ca_image = models.ImageField(upload_to='static/img/cameraman/%Y%m',
                                 storage=ImageStorage(),
                                 default='default_ca.jpg',
                                 verbose_name='摄影师照片')
    ca_lv = models.CharField(max_length=200,
                             default='初级',
                             verbose_name='摄影师等级')
    ca_gender = models.CharField(max_length=20, default='男', verbose_name='性别')
    ca_regisTime = models.DateTimeField(auto_now_add=True, verbose_name='注册时间')
Exemple #19
0
class Organization(models.Model):
    objects = OrganizationManager()
    oName = models.CharField(max_length=20)
    createTime = models.DateTimeField(auto_now_add=True)
    charge_man = models.CharField(max_length=20)
    phone_num = models.CharField(max_length=20)
    introduction = models.CharField(max_length=200)
    detail = models.TextField()
    isDelete = models.BooleanField(default=False)
    img = models.ImageField(max_length=50,
                            upload_to='static/media/%Y%m',
                            storage=ImageStorage(),
                            default='/static/img/society/society01.jpg')

    class Meta:
        db_table = 'organization'
Exemple #20
0
class Blog(models.Model, ReadNumExpandMethod):
    title = models.CharField(max_length=50)
    blog_type = models.ForeignKey(BlogType, on_delete=models.DO_NOTHING)
    content = RichTextUploadingField()
    author = models.ForeignKey(User, on_delete=models.DO_NOTHING)
    read_details = GenericRelation(ReadDetail)
    photo = models.ImageField(upload_to='upload/%Y/%m/%d',
                              storage=ImageStorage(),
                              default='uimeis_main.jpg')

    created_time = models.DateTimeField(auto_now_add=True)
    last_updated_time = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.title

    class Meta:
        ordering = ['-created_time']  # 按最新文章排序
Exemple #21
0
class School(models.Model):
	school_id = models.CharField('学校编号',max_length = 20,primary_key = True)
	school_name = models.CharField('学校名称',max_length = 200)
	school_badge = models.ImageField('校徽',upload_to = './badge/',storage = ImageStorage(),null = True)
	school_motto = models.CharField('校训',max_length = 100,null =True)
	school_address = models.CharField('学校地址',max_length = 200,null = True)
	school_location = models.CharField('所在地',max_length = 100,null = True)
	school_mold = models.CharField('学校类型',max_length = 100,null = True)
	school_url = models.URLField('学校网址',null = True)
	school_tel = models.CharField('联系电话',max_length = 100,null = True)
	school_abst = models.TextField('学校简介',null = True)

	def __str__(self):
		return self.school_name

	class Meta:
		verbose_name = '院校管理'
		verbose_name_plural = '院校管理'
Exemple #22
0
class Image(models.Model):
    """图片上传模型类"""
    ima_name = models.ForeignKey(User,
                                 max_length=20,
                                 null=True,
                                 verbose_name='图片对应的用户')
    img_url = models.ImageField(
        upload_to='static/userimages',
        storage=ImageStorage(),
        verbose_name='上传的图片')  # upload_to指定图片上传的途径,如果不存在则自动创建
    content_one = models.CharField(max_length=200,
                                   blank=True,
                                   verbose_name='信息1')
    content_two = models.CharField(max_length=200,
                                   blank=True,
                                   verbose_name='信息2')

    class Meta:
        db_table = 'tb_image'
Exemple #23
0
class Book(models.Model):
    bname = models.CharField(max_length=64, verbose_name='图书名称')
    image = models.ImageField(upload_to='', storage=ImageStorage())
    publish = models.CharField(max_length=64, verbose_name='出版社')
    author = models.CharField(max_length=64, verbose_name='作者')
    bookcategory = models.ForeignKey(BookCategory,
                                     on_delete=models.CASCADE,
                                     verbose_name='图书馆类别')
    create_time = models.DateTimeField(auto_now=True, verbose_name='录入时间')

    class Meta:
        verbose_name = '图书管理'
        verbose_name_plural = verbose_name

    def image_tag(self):
        from Bookmanager.settings import MEDIA_URL
        return '<img height=100px src="%s%s" />' % (MEDIA_URL, self.image)

    image_tag.short_description = '图书封面'
    image_tag.allow_tags = True
Exemple #24
0
class User(models.Model):
    # required
    UserID = models.AutoField(primary_key = True)
    Email = models.CharField(max_length = 30)
    Password = models.CharField(max_length = 20)
    # 不实现 类别: 学生/组织 
    # Class = models.IntegerField(default = 0)
    Nickname = models.CharField(max_length = 20)
    Gender = models.CharField(max_length = 10, default = 'male')

    # not required
    Avatar = models.ImageField(upload_to = 'avatar', storage = ImageStorage(), default = 'avatar/default.jpg') 
    Grade = models.CharField(max_length = 4, default = '2018')
    College = models.CharField(max_length = 30, default = '未填写')
    Major = models.CharField(max_length = 20, default = '未填写')
    StudentID = models.IntegerField(default = 0)
    RealName = models.CharField(max_length = 12, default = '未填写')

    def __str__(self):
        return '%d: [%s][%s]' % (self.UserID, self.Email, self.Nickname)
class User(models.Model):
    TEACHER = "Teacher"
    STUDENT = "Student"
    USER_TYPE_CHOICE = [
        (TEACHER, "老师"),
        (STUDENT, "学生"),
    ]
    username = models.CharField(max_length=20,
                                primary_key=True,
                                verbose_name="用户名")
    password = models.CharField(max_length=20, verbose_name="密码")
    nickname = models.CharField(max_length=20,
                                default="null",
                                verbose_name="昵称")
    portrait = models.ImageField(verbose_name='头像',
                                 upload_to='portraits',
                                 default='portraits/no_portrait.png',
                                 storage=ImageStorage())
    user_type = models.CharField(max_length=10,
                                 choices=USER_TYPE_CHOICE,
                                 default=STUDENT,
                                 verbose_name="用户类别")
    school = models.CharField(max_length=15,
                              verbose_name="所在院校",
                              null=True,
                              blank=True)
    email = models.EmailField(verbose_name="电子邮件", null=True, blank=True)
    belong_to_class = models.ForeignKey(Class,
                                        on_delete=models.PROTECT,
                                        verbose_name="所在班级",
                                        related_name="user_to_class",
                                        null=True,
                                        blank=True)

    def __str__(self):
        return self.nickname

    class Meta:
        ordering = ['-user_type']
Exemple #26
0
class Pic(models.Model):
    companyname = models.ForeignKey(Company, verbose_name='公司名称')
    ziplink = models.FileField(verbose_name='zip文档链接',
                               upload_to='photos/%Y/%m/%d',
                               storage=ImageStorage())
    pdflink = models.FileField(verbose_name='pdf文档链接',
                               blank=True,
                               null=True,
                               upload_to='photos/%Y/%m/%d')
    cate = models.ForeignKey(Cate, verbose_name='证件类型')
    downloads = models.IntegerField(verbose_name='下载次数', default=0)
    create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    create_date = models.DateField(verbose_name='创建日期', auto_now_add=True)
    status = models.CharField(verbose_name='状态',
                              choices=(('正式', '正式'), ('作废', '作废')),
                              max_length=10,
                              default="正式")

    def __str__(self):
        return "%s" % self.id

    class Meta:
        verbose_name = '电子档案'
        verbose_name_plural = verbose_name
Exemple #27
0
class SamllImage(models.Model):
    samllimg1 = models.ImageField(upload_to='index/samllimg1',
                                  storage=ImageStorage(),
                                  verbose_name='图片1')
    samllimg2 = models.ImageField(upload_to='index/samllimg2',
                                  storage=ImageStorage(),
                                  verbose_name='图片2')
    samllimg3 = models.ImageField(upload_to='index/samllimg3',
                                  storage=ImageStorage(),
                                  verbose_name='图片3')
    samllimg4 = models.ImageField(upload_to='index/samllimg4',
                                  storage=ImageStorage(),
                                  verbose_name='图片4')
    samllimg5 = models.ImageField(upload_to='index/samllimg5',
                                  storage=ImageStorage(),
                                  verbose_name='图片5')
    samllimg6 = models.ImageField(upload_to='index/samllimg6',
                                  storage=ImageStorage(),
                                  verbose_name='图片6')

    class Meta:
        verbose_name = '小轮播图'
        verbose_name_plural = '小轮播图'