コード例 #1
0
ファイル: forms.py プロジェクト: kunxin-chor/django-lms
class CourseForm(forms.ModelForm):
    image = ImageField(label='Cover Photo')

    class Meta:
        model = Course
        fields = ('title', 'desc', 'number_of_hours', 'instructor', 'image',
                  'cost')
コード例 #2
0
class ListingForm(forms.ModelForm):
    listing_photo = ImageField(widget=FileWidget(attrs={
        'data-public-key':'c1c0ea35a4b3421770fa',
        'data-images-only':'True',
        'data-preview-step':'True',
    }))
    class Meta:
        model = Listing
        fields = ('name','description','price','used','location','listing_photo','categories')
        exclude = ['seller']
        
        
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column('name', css_class='form-group col-md-6 mb-0'),
                Column('price', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'
            ),
            'description',
            'location',
            Row(
                Column('categories', css_class='form-group col-md-6 mb-0 categories_form_custom_css'),
                Column('listing_photo', css_class='form-group col-md-4 mb-0'),
                Column('used', css_class='form-group col-md-2 mb-0'),
                css_class='form-row'
            ),
            Submit('submit', 'Create Listing', css_class="btn essence-btn")
        )
コード例 #3
0
    class Meta:
        image = ImageField(label='')

        model = healthfood
        fields = ('title', 'description', 'image', 'maker',
                  'serving', 'country', 'ingredients', 'nutrition_carbs', 'nutrition_protein',
                  'nutrition_fats', 'cost')
コード例 #4
0
class CourseForm(forms.ModelForm):
    image = ImageField(widget=FileWidget(attrs={'data-clearable': True}))

    class Meta:
        model = Course
        fields = ('title', 'desc', 'number_of_hours', 'instructor', 'image',
                  'cost')
コード例 #5
0
class Guitarsform(forms.ModelForm):
    image = ImageField(widget=FileWidget(attrs={'data-clearable': True}))

    class Meta:
        model = Guitars
        fields = ('brand', 'model', 'desc', 'prod_year', 'cost', 'stockrem',
                  'image')
コード例 #6
0
class ProductForm(forms.ModelForm):
    image = ImageField(label='', required=False)

    class Meta:
        model = Product
        fields = ('title', 'image', 'desc', 'price', 'category', 'tag',
                  'video')
コード例 #7
0
class RegisterForm(UserCreationForm):
    profile_picture = ImageField(widget=FileWidget(attrs={
        'data-public-key':'c1c0ea35a4b3421770fa',
        'data-images-only':'True',
        'data-preview-step':'True',
    }))
    
    class Meta:
        model = UserAccount
        fields = ('username','first_name','last_name','email','password1','password2','profile_picture')
        
    def clean_username(self):
        requested_username = self.cleaned_data.get('username')
        if UserAccount.objects.filter(username=requested_username).count() > 0:
            raise forms.ValidationError("This username is already taken.")
        return requested_username
            
    def save(self, commit=True):
        UserAccount = super(RegisterForm, self).save(commit=False)
        UserAccount.email = self.cleaned_data["email"]
        UserAccount.first_name = self.cleaned_data["first_name"]
        UserAccount.last_name = self.cleaned_data["last_name"]
 
        if commit:
            UserAccount.save()
            return UserAccount
コード例 #8
0
class CommentForm(forms.ModelForm):
    image = ImageField(label='', required=False)

    class Meta:
        model = Comment
        fields = (
            'body',
            'image',
        )
コード例 #9
0
class MentorForm(forms.ModelForm):
    image_preview = ImageField(label='Wybierz zdjęcie')
    video_presentation = FileField(label='Wybierz wideo')

    class Meta:
        model = Mentor
        fields = ('title', 'category', 'language', 'price', 'who_am_i',
                  'what_can_i_teach_you', 'description', 'requirements',
                  'image_preview', 'video_presentation', 'status')
コード例 #10
0
class PostForm(forms.ModelForm):
    caption = forms.CharField(widget=forms.Textarea(attrs={"class":"form-control",
                                                           "placeholder":"Caption...",
                                                           "rows":"4"}))
    image = ImageField(label='', manual_crop="800x800")

    class Meta:
        model = Post
        fields = ("caption", "image",)
コード例 #11
0
class PostForm(forms.ModelForm):
    photo = ImageField(label='')

    class Meta:
        model = Post
        fields = (
            'content',
            'photo',
        )
コード例 #12
0
class CreateView(LoginRequiredMixin, CreateView):
    photo = ImageField(label='post')

    model = Project
    success_url = '/'
    template_name = 'post_form.html'
    fields = ['title', 'description', 'photo', 'link']

    def form_valid(self, form):
        form.instance.account = self.request.user
        return super().form_valid(form)
コード例 #13
0
ファイル: forms.py プロジェクト: vikvik98/ProjetoFinalPi
class AddPostForm(forms.Form):
    text = forms.CharField(required=False)
    photo = ImageField(required=False)

    def clean(self):
        cleaned_data = super().clean()
        text = cleaned_data.get('text')
        photo = cleaned_data.get('photo')
        if not text and not photo:
            raise forms.ValidationError(_("Please, add a photo or text."))
        return cleaned_data
コード例 #14
0
class ProfileEditForm(ModelForm):
    photo = ImageField(widget=FileWidget(attrs={
        'data-image-shrink': '1024x1024',
        'data-tabs': 'file url facebook instagram',
        'data-preview-step': 'true',
        'data-crop' : 'free 16:9 4:3 5:4 1:1'
    }))

    class Meta:
        model = Profile
        fields = ['photo', 'bio', 'facebook', 'www']
コード例 #15
0
class CreateView(LoginRequiredMixin, CreateView):
    image = ImageField(label='post')

    model = Image
    success_url = '/'
    template_name = 'insta/post_form.html'
    fields = ['name', 'caption', 'image']

    def form_valid(self, form):
        form.instance.account = self.request.user
        return super().form_valid(form)
コード例 #16
0
class PostForm(forms.ModelForm):
    photo = ImageField(label='')

    class Meta:
        model = Post
        fields = (
            'photo',
            'title',
            'url',
            'description',
            'technologies',
        )
コード例 #17
0
ファイル: forms.py プロジェクト: yucheng91/CI4-walkiedoggie
class PostForm(forms.ModelForm):
    cover = ImageField(label='Photo', manual_crop="25:16")

    class Meta:
        model = Post
        labels = {
            "title": "Name",
            "age": "Estimated Age",
            "sex": "Gender",
            "content": "Intro"
        }
        fields = ('title', 'age', 'sex', 'content', 'cover')
コード例 #18
0
class BoardForm(ModelForm):

    image = ImageField(widget=FileWidget(
        attrs={
            'data-image-shrink': '2024x2024',
            'data-tabs': 'file url',
            'data-preview-step': 'true',
            'data-crop': 'free 16:9 4:3 5:4 1:1'
        }))

    class Meta:
        model = Board
        fields = ['title', 'image', 'body']
コード例 #19
0
class UpdateProfileForm(forms.ModelForm):
    profile_pic = ImageField(label='')

    class Meta:
        model = Profile
        fields = ("bio", "profile_pic")
        widgets = {
            "bio":
            forms.Textarea(attrs={
                "class": "form-control mb-4",
                "value": "user.profile.bio"
            }),
        }
コード例 #20
0
ファイル: models.py プロジェクト: ALKEMIA-CHARLES/gallery-app
class Images(models.Model):
    image = ImageField(manual_crop="700x700")
    image_name = models.CharField(max_length=100)
    image_descrition = models.CharField(max_length=100)
    categories = models.ManyToManyField(Category, related_name='threads')
    location = models.ForeignKey(Location, on_delete=models.CASCADE)
    post_date = models.DateTimeField(auto_now_add=True)
    image_url = models.URLField(max_length=250)

    def __str__(self):
        return self.image_name

    def save_image(self):
        return self.save()

    def get_remote_image(self):
        if self.image_url and not self.image:
            result = request.urlretrieve(self.image_url)
        self.image.save(os.path.basename(self.image_url),
                        File(open(result[0], 'rb')))
        self.save()

    def admin_image(self):
        return '<img src="%s"/>' % self.image

    admin_image.allow_tags = True

    @classmethod
    def copy_url(cls, id):
        image = cls.objects.get(id=id)
        pyperclip.copy(image.image.url)

    @classmethod
    def delete_image(cls, id):
        return cls.objects.filter(id=id).delete()

    @classmethod
    def show_images(cls):
        return cls.objects.order_by("post_date")[::1]

    @classmethod
    def filter_by_location(cls, id):
        return cls.objects.filter(location__id=id)

    @classmethod
    def get_image_by_id(cls, id):
        return cls.objects.filter(id=id)[0]

    @classmethod
    def search_image_by_category(cls, search):
        return cls.objects.filter(categories__name__icontains=search)
コード例 #21
0
class UpdatePostView(LoginRequiredMixin, UserPassesTestMixin, UpdateView):
    image = ImageField(label='post')

    model = Image
    success_url = '/'
    template_name = 'insta/post_form.html'
    fields = ['name', 'caption', 'image']

    def form_valid(self, form):
        form.instance.account = self.request.user
        return super().form_valid(form)

    def test_func(self):
        post = self.get_object()
        if self.request.user == post.account:
            return True
        return False
コード例 #22
0
class ProjectForm(forms.ModelForm):
    project_pic = ImageField(label='')

    class Meta:
        model = Project
        fields = (
            "title",
            "description",
            "project_pic",
            "live_site",
        )
        widgets = {
            "title": forms.TextInput(attrs={"class": "form-control mb-4"}),
            "description": TinyMCE(attrs={
                'cols': 116,
                'rows': 15
            }),
            "live_site": forms.URLInput(attrs={"class": "form-control mb-4"}),
        }
コード例 #23
0
class DBUSER(models.Model):
    name= models.CharField(max_length=100)
    image = ImageField(manual_crop="700x700")
    db_comment = CharField(max_length=100)
    likes = IntegerField()
    post_date = models.DateTimeField(auto_now_add=True)
    image_url = models.URLField(max_length=250)

    def __str__(self):
        return self.name
    def save_db_user(self):
        return self.save()
    def get_remote_image(self):
        if self.image_url and not self.image:
            result = request.urlretrieve(self.image_url)
        self.image.save(
                os.path.basename(self.image_url),
                File(open(result[0], 'rb'))
                )
        self.save()
コード例 #24
0
ファイル: forms.py プロジェクト: leigh93/newdirectory
class AddAgencyForm(forms.ModelForm):
    agencyname = forms.CharField(label='Agency Name', max_length=200)
    registration_no = forms.IntegerField(label='Registration Number')
    agency_logo = ImageField(label='Add agency')

    # agency_image = CloudinaryFileField(
    #     options = {
    #         'crop': 'thumb',
    #         'width': 200,
    #         'height': 200,
    #         'folder': 'avatars'
    #    }
    # )

    class Meta:
        model = Agency
        fields = (
            'agencyname',
            'registration_no',
            'agency_logo',
        )
コード例 #25
0
class ProjectForm(forms.ModelForm):
    cover_photo = ImageField(label='')
    url = forms.URLField(label='Live site')
    widgets = {
        "title":
        forms.TextInput(attrs={"class": "form-control mb-4"}),
        "description":
        forms.Textarea(attrs={
            'cols': 110,
            'rows': 15,
            "class": "form-control mb-4"
        }),
        "live_site":
        forms.URLInput(attrs={"class": "form-control mb-4"}),
        "technologies":
        forms.TextInput(attrs={"class": "form-control mb-4"}),
    }

    class Meta:
        model = Project
        fields = ('title', 'description', 'cover_photo', 'url', 'technologies')
コード例 #26
0
class ProductForm(forms.ModelForm):
    product_picture = ImageField(widget=FileWidget(
        attrs={
            'data-public-key': '47e54d77c7a9f66c3f0c',
            'data-images-only': 'True',
            'data-preview-step': 'True',
            'data-image-shrink': '500x500',
            'data-crop': '1:1',
        }))

    seller_id = forms.CharField(widget=forms.HiddenInput(
        attrs={'readonly': 'readonly'}))

    class Meta:
        model = Product
        fields = '__all__'
        exclude = ('views', )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(Column('product_picture',
                       css_class='form-group col-md-6 mb-0'),
                Column(Row(Column('name', css_class="form-group col mb-0"),
                           css_class="form-row"),
                       Row(Column('price', css_class="form-group col mb-0"),
                           Column('year', css_class="form-group col mb-0"),
                           css_class="form-row"),
                       css_class='form-group col-md-6 mb-0'),
                css_class='form-row'),
            Row(Column('quantity_in_stock', css_class="col"),
                css_class='form-row'),
            Row(Column('description', css_class="col"), css_class='form-row'),
            Row(Column('seller_id', css_class="col"), css_class='form-row'),
            Row(Column('region', css_class='form-group col-md-4 mb-0'),
                Column('body', css_class='form-group col-md-4 mb-0'),
                Column('nodes', css_class='form-group col-md-4 mb-0'),
                css_class='form-row'),
            Submit('submit', 'Save Listing', css_class="btn"))
コード例 #27
0
class AvatarForm(forms.ModelForm):
    profile_img = ImageField(label='', required=False)

    class Meta:
        model = Photographer
        fields = ('profile_img', )
コード例 #28
0
ファイル: forms.py プロジェクト: diyanah08/django-userauth
class ItemForm(forms.ModelForm):
    photos = ImageField(label="image")

    class Meta:
        model = Item
        fields = ('name', 'done', 'category', 'tags', 'photos')
コード例 #29
0
class ImgForm(forms.Form):
    picImg = ImageField(label='')
コード例 #30
0
 class Meta:
     image = ImageField(widget=FileWidget(attrs={'data-clearable':True}))
     model=Game
     # fields will display on form as arranged 
     fields=('name', 'category', 'description', 'inside_box', 'price', 'image', 'homepage_display')