modules/freifunk: Change default netmask to 255.255.0.0, change non-working dns,...
[project/luci.git] / modules / freifunk / luasrc / model / cbi / freifunk / profile_expert.lua
index d737132..a0b8f34 100644 (file)
@@ -12,26 +12,30 @@ You may obtain a copy of the License at
 
 local fs = require "nixio.fs"
 local uci = require "luci.model.uci".cursor()
-local community = "/etc/config/profile_" .. uci:get("freifunk", "community", "name")
-
-f = SimpleForm("community", translate("Community profile"), 
-       translate("You can manually edit the selected community profile here."))
-
-t = f:field(TextValue, "cop")
-t.rmempty = true
-t.rows = 30
-function t.cfgvalue()
-       return fs.readfile(community) or ""
-end
+local community = uci:get("freifunk", "community", "name")
+
+if community == nil then
+        luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "profile_error"))
+        return
+else
+        community = "/etc/config/profile_" .. community
+       f = SimpleForm("community", translate("Community profile"), translate("You can manually edit the selected community profile here."))
+
+       t = f:field(TextValue, "cop")
+       t.rmempty = true
+       t.rows = 30
+       function t.cfgvalue()
+               return fs.readfile(community) or ""
+       end
 
-function f.handle(self, state, data)
-       if state == FORM_VALID then
-               if data.cop then
-                       fs.writefile(cop, data.rcs:gsub("\r\n", "\n"))
+       function f.handle(self, state, data)
+               if state == FORM_VALID then
+                       if data.cop then
+                               fs.writefile(cop, data.rcs:gsub("\r\n", "\n"))
+                       end
                end
+               return true
        end
-       return true
+       return f
 end
 
-return f
-