Browse Source

public theme prototype

current_wdka_release
crunk 3 years ago
parent
commit
538394dfef
  1. 6
      verse/distribusisinfo.py
  2. 5
      verse/editor.py
  3. 16
      verse/forms/publicthemeform.py
  4. 4
      verse/forms/themeform.py
  5. 13
      verse/start.py
  6. 28
      verse/templates/distribusiworkflow/theme.html
  7. 48
      verse/themeselector.py

6
verse/distribusisinfo.py

@ -18,7 +18,9 @@ class DistribusisInfo:
Distribusis.publictheme.isnot(None) Distribusis.publictheme.isnot(None)
).all() ).all()
for distribusi in distribusis: for distribusi in distribusis:
publicthemes.append( publictheme = (
f"{distribusi.publictheme} used in {distribusi.distribusiname}" f"{distribusi.distribusiname}/{distribusi.publictheme}",
f"{distribusi.publictheme} used in {distribusi.distribusiname}",
) )
publicthemes.append(publictheme)
return publicthemes return publicthemes

5
verse/editor.py

@ -19,6 +19,7 @@ from distribusisinfo import DistribusisInfo
from forms.uploadform import UploadForm from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm
from forms.editorform import EditorForm from forms.editorform import EditorForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
@ -92,7 +93,8 @@ def RenderDistribusiTemplate(current_distribusi):
uploadform = UploadForm() uploadform = UploadForm()
distribusiform = DistribusiForm() distribusiform = DistribusiForm()
themeform = ThemeForm() themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes() publicthemeform = PublicThemeForm()
publicthemeform.publicthemes.choices = DistribusisInfo.publicthemes()
selectorform = SelectorForm() selectorform = SelectorForm()
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
@ -105,6 +107,7 @@ def RenderDistribusiTemplate(current_distribusi):
uploadform=uploadform, uploadform=uploadform,
distribusiform=distribusiform, distribusiform=distribusiform,
themeform=themeform, themeform=themeform,
publicthemeform=publicthemeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
distribusi_live=distribusi_live, distribusi_live=distribusi_live,

16
verse/forms/publicthemeform.py

@ -0,0 +1,16 @@
"""Form object declaration."""
from flask_wtf import FlaskForm
from wtforms import (
RadioField,
SubmitField,
)
class PublicThemeForm(FlaskForm):
"""PublicTheme selection form."""
publicthemes = RadioField(
"Public themes from other distribusi-verse users:"
)
save = SubmitField("Save")

4
verse/forms/themeform.py

@ -18,8 +18,4 @@ class ThemeForm(FlaskForm):
], ],
) )
publicthemes = RadioField(
"Public themes from other distribusi-verse users:"
)
save = SubmitField("Save") save = SubmitField("Save")

13
verse/start.py

@ -26,6 +26,7 @@ from distribusimodel import Distribusis
from forms.uploadform import UploadForm from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
# CRUD! # CRUD!
@ -105,7 +106,8 @@ def distribusi():
uploadform = UploadForm() uploadform = UploadForm()
distribusiform = DistribusiForm() distribusiform = DistribusiForm()
themeform = ThemeForm() themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes() publicthemeform = PublicThemeForm()
publicthemeform.publicthemes.choices = DistribusisInfo.publicthemes()
selectorform = SelectorForm() selectorform = SelectorForm()
selectorform.distribusis.choices = DistribusisInfo.userdistribusis() selectorform.distribusis.choices = DistribusisInfo.userdistribusis()
@ -152,6 +154,7 @@ def distribusi():
uploadform=uploadform, uploadform=uploadform,
distribusiform=distribusiform, distribusiform=distribusiform,
themeform=themeform, themeform=themeform,
publicthemeform=publicthemeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
distribusi_live=distribusi_live, distribusi_live=distribusi_live,
@ -166,7 +169,8 @@ def distribusi():
def upload(): def upload():
distribusiform = DistribusiForm() distribusiform = DistribusiForm()
themeform = ThemeForm() themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes() publicthemeform = PublicThemeForm()
publicthemeform.publicthemes.choices = DistribusisInfo.publicthemes()
selectorform = SelectorForm() selectorform = SelectorForm()
selectorform.distribusis.choices = DistribusisInfo.userdistribusis() selectorform.distribusis.choices = DistribusisInfo.userdistribusis()
selectorvisible = SelectorVisible() selectorvisible = SelectorVisible()
@ -183,6 +187,7 @@ def upload():
uploadform=uploadform, uploadform=uploadform,
distribusiform=distribusiform, distribusiform=distribusiform,
themeform=themeform, themeform=themeform,
publicthemeform=publicthemeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
distribusi_live=distribusi_live, distribusi_live=distribusi_live,
@ -211,7 +216,8 @@ def selector():
uploadform = UploadForm() uploadform = UploadForm()
distribusiform = DistribusiForm() distribusiform = DistribusiForm()
themeform = ThemeForm() themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes() publicthemeform = PublicThemeForm()
publicthemeform.publicthemes.choices = DistribusisInfo.publicthemes()
selectorform = SelectorForm() selectorform = SelectorForm()
selectorform.distribusis.choices = DistribusisInfo.userdistribusis() selectorform.distribusis.choices = DistribusisInfo.userdistribusis()
current_distribusi = CurrentDistribusi() current_distribusi = CurrentDistribusi()
@ -250,6 +256,7 @@ def selector():
uploadform=uploadform, uploadform=uploadform,
distribusiform=distribusiform, distribusiform=distribusiform,
themeform=themeform, themeform=themeform,
publicthemeform=publicthemeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
distribusi_live=distribusi_live, distribusi_live=distribusi_live,

28
verse/templates/distribusiworkflow/theme.html

@ -1,20 +1,36 @@
<div id="theme" class="workflow"> <div id="theme" class="workflow">
<h3>(Optional) Step 2: Theme</h3> <h3>(Optional) Step 2: Choose a Theme</h3>
<p>Select your Theme here. If you want your own custom css, skip and go to <p>Select your Theme here. If you want to make own custom css, skip and go to
step 3. Don't forget to press Save</p> step 3.</p>
<p>Don't forget to press Save</p>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('theme') }}"> <form method="POST" enctype="multipart/form-data" action="{{ url_for('theme') }}">
{{ themeform.csrf_token }} {{ themeform.csrf_token }}
<fieldset class="required"> <fieldset class="required">
{{ themeform.theme.label }} {{ themeform.theme.label }}
{{ themeform.theme }} {{ themeform.theme }}
</fieldset> </fieldset>
{% if files_uploaded or distribusi_live %}
<fieldset class="button required">
{{ themeform.save }}
</fieldset>
{% else %}
<p>
You need to upload your files first before you can a css theme
for your files.
</p>
<a href="#upload">Go to Step 1</a>
{% endif %}
</form>
<hr>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('theme') }}">
{{ publicthemeform.csrf_token }}
<fieldset class="required"> <fieldset class="required">
{{ themeform.publicthemes.label }} {{ publicthemeform.publicthemes.label }}
{{ themeform.publicthemes }} {{ publicthemeform.publicthemes }}
</fieldset> </fieldset>
{% if files_uploaded or distribusi_live %} {% if files_uploaded or distribusi_live %}
<fieldset class="button required"> <fieldset class="button required">
{{ themeform.save }} {{ publicthemeform.save }}
</fieldset> </fieldset>
{% else %} {% else %}
<p> <p>

48
verse/themeselector.py

@ -12,39 +12,44 @@ from distribusisinfo import DistribusisInfo
from forms.uploadform import UploadForm from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
def ThemeSelector(): def ThemeSelector():
themeform = ThemeForm() themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes() publicthemeform = PublicThemeForm()
publicthemeform.publicthemes.choices = DistribusisInfo.publicthemes()
current_distribusi = CurrentDistribusi() current_distribusi = CurrentDistribusi()
if themeform.validate_on_submit(): if themeform.validate_on_submit():
newcssfolder = os.path.join("themes/userthemes", current_distribusi) copycssfile = os.path.join(
if not os.path.exists(newcssfolder): "themes",
os.mkdir(newcssfolder) f"{themeform.theme.data}.css",
if themeform.theme.data: )
copycssfile = os.path.join( MoveCssToUserFolder(current_distribusi, copycssfile)
"themes", if publicthemeform.validate_on_submit():
f"{themeform.theme.data}.css", copycssfile = os.path.join(
) "themes/publicthemes/",
if themeform.publicthemes.data: f"{publicthemeform.publicthemes.data}.css",
publictheme = themeform.publicthemes.data )
copycssfile = os.path.join( MoveCssToUserFolder(current_distribusi, copycssfile)
"themes/publicthemes", return RenderDistribusiTemplate(
f"{distribusiname}", themeform,
f"{themename}.css", publicthemeform,
) current_distribusi
shutil.copy(copycssfile, newcssfolder) )
return RenderDistribusiTemplate(current_distribusi) def MoveCssToUserFolder(current_distribusi, copycssfile):
newcssfolder = os.path.join("themes/userthemes", current_distribusi)
if not os.path.exists(newcssfolder):
os.mkdir(newcssfolder)
shutil.copy(copycssfile, newcssfolder)
def RenderDistribusiTemplate(current_distribusi): def RenderDistribusiTemplate(themeform, publicthemeform, current_distribusi):
uploadform = UploadForm() uploadform = UploadForm()
distribusiform = DistribusiForm() distribusiform = DistribusiForm()
themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes()
selectorform = SelectorForm() selectorform = SelectorForm()
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
@ -57,6 +62,7 @@ def RenderDistribusiTemplate(current_distribusi):
uploadform=uploadform, uploadform=uploadform,
distribusiform=distribusiform, distribusiform=distribusiform,
themeform=themeform, themeform=themeform,
publicthemeform=publicthemeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
distribusi_live=distribusi_live, distribusi_live=distribusi_live,

Loading…
Cancel
Save