Repository: OpenEnergyPlatform/oeplatform

Issue:
[Factsheets] Fact sheets Documentation text fields
The text fields for the link to the documentations should not be mandatory - taking the case, where the documentation is not online available, into account. Please, make in the info text clear, that a link is expected.

The quality rating was meant to be located next to link and not underneath.



Discussion:

Resolving patch:
diff --git a/modelview/models.py b/modelview/models.py
--- a/modelview/models.py
+++ b/modelview/models.py
@@ -21,14 +21,14 @@ class BasicFactsheet(models.Model):
     framework = BooleanField(default=False,verbose_name='Framework', help_text='Is the model based on a framework? If yes, which?') 
     framework_yes_text = CharField(max_length=1000,null=True) 
 
-    user_documentation = URLField(verbose_name='User Documentation', help_text='Where is the user documentation publicly available?', null=False) 
-    code_documentation = URLField(verbose_name='Developer/Code Documentation', help_text='Where is the code documentation publicly available?', null=False)
+    user_documentation = URLField(verbose_name='Link to User Documentation', help_text='Where is the user documentation publicly available?', null=True) 
+    code_documentation = URLField(verbose_name='Link to Developer/Code Documentation', help_text='Where is the code documentation publicly available?', null=True)
     documentation_quality = CharField(max_length=1000,verbose_name='Documentation quality', help_text='How is the quality of the documentations?', choices=(('expandable', 'expandable'), ('good', 'good'), ('excellent', 'excellent')), default='expandable') 
     source_of_funding = CharField(max_length=200,verbose_name='Source of funding', help_text="What's the main source of funding?", null=True) 
     open_source = BooleanField(default=False,verbose_name='Open Source') 
     open_up = BooleanField(default=False,verbose_name='Planned to open up in the future', help_text='Will the source code be available in future?') 
     costs = CharField(max_length=1000,verbose_name='Costs', null=True) 
-    license = CharField(max_length=1000,verbose_name='License', choices=(('Apache', 'Apache'), ('Other', 'Other')), default='Apache') 
+    license = CharField(max_length=20,verbose_name='License', choices=((x,x) for x in ["MIT Licence", "Apache Licence", "GNU GPL Licence", "Other"]), default='Apache Licence') 
     license_other_text = CharField(max_length=1000,null=True)
     source_code_available = BooleanField(default=False,verbose_name='Source code available', help_text='Is the source code directly downloadable?') 
     gitHub = BooleanField(default=False,verbose_name='GitHub', help_text='Is the model available on GitHub?') 
@@ -125,7 +125,7 @@ class Energymodel(BasicFactsheet):
     storage_gas = BooleanField(default=False,verbose_name='gas') 
 
     user_behaviour = BooleanField(default=False,verbose_name='User behaviour and demand side management', help_text='How can user behaviour changes and demand side management be considered?') 
-    user_behaviour_yes_text = CharField(max_length=200,null=True) 
+    user_behaviour_yes_text = TextField(null=True) 
 
     market_models = BooleanField(default=False,verbose_name='Market models', help_text='Which / Is a market models are included?') 
 
@@ -145,7 +145,7 @@ class Energymodel(BasicFactsheet):
     geo_resolution_others = BooleanField(default=False,verbose_name='others') 
     geo_resolution_others_text = CharField(max_length=200,null=True)
 
-    comment_on_geo_resolution = CharField(max_length=200,verbose_name='Comment on geographic (spatial) resolution', help_text='Feel free to explain the geographical resolution of the model e.g. with regard to the grid data.', null=True) 
+    comment_on_geo_resolution = TextField(verbose_name='Comment on geographic (spatial) resolution', help_text='Feel free to explain the geographical resolution of the model e.g. with regard to the grid data.', null=True) 
 
     time_resolution_anual = BooleanField(default=False,verbose_name='anual') 
     time_resolution_hour = BooleanField(default=False,verbose_name='hour') 
@@ -183,7 +183,7 @@ class Energymodel(BasicFactsheet):
     model_class_other = BooleanField(default=False,verbose_name='Other') 
     model_class_other_text = CharField(max_length=1000,null=True) 
 
-    short_description_of_mathematical_model_class = CharField(max_length=1000,verbose_name='Short description of mathematical model class', null=True) 
+    short_description_of_mathematical_model_class = TextField(verbose_name='Short description of mathematical model class', null=True) 
 
     mathematical_objective_cO2 = BooleanField(default=False,verbose_name='CO2') 
     mathematical_objective_costs = BooleanField(default=False,verbose_name='costs') 
diff --git a/modelview/templatetags/modelview_extras.py b/modelview/templatetags/modelview_extras.py
--- a/modelview/templatetags/modelview_extras.py
+++ b/modelview/templatetags/modelview_extras.py
@@ -47,7 +47,7 @@ def checklist(model,labels):
                 first=False
             else:
                 s+=", "
-            s+= model.__dict__[text]
+            s+= str(model.__dict__[text])
     if s == "":
         s = "-"
     return s
@@ -98,6 +98,13 @@ def get_field_attr(instance, field_name, attr, cut=None):
         val = val.replace(cut,"")
     return val
     
+@register.assignment_tag
+def set_val(val):
+    """
+    Returns verbose_name for a field.
+    """
+    return val    
+    
 @register.assignment_tag
 def assign_field_attr(instance, field_name, attr):
     """
@@ -120,3 +127,14 @@ def year_field(instance, field_name):
 @register.filter
 def addEvent(value, arg):
     return value.as_widget(attrs={arg: value.name+"_click(this)"})
+
+@register.assignment_tag
+def assignClass(field, css):
+    class_old = field.field.widget.attrs.get('class', None)
+    class_new = class_old + ' ' + css if class_old else css
+    field.field.widget.attrs['class'] = class_new
+    return field
+   
+@register.filter
+def addClass(value, arg):
+    return value.as_widget(attrs={'class': arg})


Test patch: