2019-03-09 19:11:42 +00:00
|
|
|
from crispy_forms.helper import FormHelper
|
|
|
|
from crispy_forms.layout import Layout, Fieldset
|
2019-01-19 06:52:00 +00:00
|
|
|
from django import forms
|
2019-01-11 19:16:01 +00:00
|
|
|
from django.forms import ModelForm
|
2019-01-19 06:52:00 +00:00
|
|
|
from djconfig.forms import ConfigForm
|
2019-01-11 19:16:01 +00:00
|
|
|
|
|
|
|
from feeds.models import Feed
|
|
|
|
|
|
|
|
|
|
|
|
class FeedForm(ModelForm):
|
|
|
|
prefix = 'feed'
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Feed
|
|
|
|
exclude = 'owner', 'lock', 'config_type', 'config_id', 'last_check', 'last_id',
|
|
|
|
|
|
|
|
|
|
|
|
def get_config_form(mdl):
|
|
|
|
class ConfigForm(ModelForm):
|
|
|
|
prefix = 'config'
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = mdl
|
|
|
|
exclude = ()
|
|
|
|
return ConfigForm
|
2019-01-19 06:52:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FeedsAppConfigForm(ConfigForm):
|
|
|
|
slug = 'feeds'
|
|
|
|
title = 'Feeds'
|
|
|
|
|
|
|
|
feed_bot_token = forms.CharField(required=True)
|
2019-03-09 19:11:42 +00:00
|
|
|
|
2019-01-26 06:36:56 +00:00
|
|
|
russian_proxy_string = forms.CharField()
|
2019-01-19 06:52:00 +00:00
|
|
|
vk_username = forms.CharField(required=True)
|
|
|
|
vk_password = forms.CharField(required=True)
|
2019-01-25 16:33:22 +00:00
|
|
|
vk_auth = forms.CharField(required=False, widget=forms.Textarea())
|
2019-02-08 14:04:37 +00:00
|
|
|
anticaptcha_token = forms.CharField()
|
2019-03-09 19:11:42 +00:00
|
|
|
|
|
|
|
twitter_consumer_api_key = forms.CharField(required=False)
|
|
|
|
twitter_consumer_api_secret = forms.CharField(required=False)
|
|
|
|
twitter_access_token = forms.CharField(required=False)
|
|
|
|
twitter_access_token_secret = forms.CharField(required=False)
|
|
|
|
|
|
|
|
helper = FormHelper()
|
|
|
|
helper.form_class = 'form-horizontal'
|
|
|
|
helper.label_class = 'col-sm-2'
|
|
|
|
helper.field_class = 'col-sm-10'
|
|
|
|
helper.layout = Layout(
|
|
|
|
Fieldset('Global', 'feed_bot_token'),
|
|
|
|
Fieldset('VK.com', 'russian_proxy_string', 'vk_username', 'vk_password', 'vk_auth', 'anticaptcha_token'),
|
|
|
|
Fieldset('Twitter', 'twitter_consumer_api_key', 'twitter_consumer_api_secret', 'twitter_access_token',
|
|
|
|
'twitter_access_token_secret'),
|
|
|
|
)
|