upd: remove alert settings from register process
authorINOPIAE <m.maengel@inopiae.de>
Thu, 7 Dec 2017 05:29:09 +0000 (06:29 +0100)
committerLucas Werkmeister <mail@lucaswerkmeister.de>
Fri, 22 Dec 2017 23:17:40 +0000 (00:17 +0100)
Change-Id: I511ceed2f00c15902c46d31564ba4f8454fef774

src/club/wpia/gigi/database/DatabaseConnection.java
src/club/wpia/gigi/database/tableStructure.sql
src/club/wpia/gigi/database/upgrade/from_35.sql [new file with mode: 0644]
src/club/wpia/gigi/pages/main/Signup.java
src/club/wpia/gigi/pages/main/Signup.templ
tests/club/wpia/gigi/pages/main/RegisterPageTest.java

index 40eeae6..04351d1 100644 (file)
@@ -181,7 +181,7 @@ public class DatabaseConnection {
 
     }
 
-    public static final int CURRENT_SCHEMA_VERSION = 35;
+    public static final int CURRENT_SCHEMA_VERSION = 36;
 
     public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
 
index 82aedc7..8c697f7 100644 (file)
@@ -115,16 +115,6 @@ CREATE TABLE "baddomains" (
 );
 
 
-DROP TABLE IF EXISTS "alerts";
-CREATE TABLE "alerts" (
-  "memid" int NOT NULL DEFAULT '0',
-  "general" boolean NOT NULL DEFAULT 'false',
-  "country" boolean NOT NULL DEFAULT 'false',
-  "regional" boolean NOT NULL DEFAULT 'false',
-  "radius" boolean NOT NULL DEFAULT 'false',
-  PRIMARY KEY ("memid")
-);
-
 DROP TABLE IF EXISTS "user_agreements";
 CREATE TABLE "user_agreements" (
   "id" serial NOT NULL,
@@ -380,7 +370,7 @@ CREATE TABLE "schemeVersion" (
   "version" smallint NOT NULL,
   PRIMARY KEY ("version")
 );
-INSERT INTO "schemeVersion" (version)  VALUES(35);
+INSERT INTO "schemeVersion" (version)  VALUES(36);
 
 DROP TABLE IF EXISTS `passwordResetTickets`;
 CREATE TABLE `passwordResetTickets` (
diff --git a/src/club/wpia/gigi/database/upgrade/from_35.sql b/src/club/wpia/gigi/database/upgrade/from_35.sql
new file mode 100644 (file)
index 0000000..53dcc4d
--- /dev/null
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS "alerts";
index c5dcadf..d9b2cc1 100644 (file)
@@ -37,8 +37,6 @@ public class Signup extends Form {
 
     private static final Template t = new Template(Signup.class.getResource("Signup.templ"));
 
-    private boolean general = true, country = true, regional = true, radius = true;
-
     private CountrySelector cs;
 
     public Signup(HttpServletRequest hsr) {
@@ -55,10 +53,6 @@ public class Signup extends Form {
         vars.put("name", ni);
         vars.put("dob", myDoB);
         vars.put("email", HTMLEncoder.encodeHTML(email));
-        vars.put("general", general ? " checked=\"checked\"" : "");
-        vars.put("country", country ? " checked=\"checked\"" : "");
-        vars.put("regional", regional ? " checked=\"checked\"" : "");
-        vars.put("radius", radius ? " checked=\"checked\"" : "");
         vars.put("helpOnNames", new SprintfCommand("Help on Names {0}in the wiki{1}", Arrays.asList("!(/wiki/names", "!'</a>")));
         vars.put("csrf", getCSRFToken());
         vars.put("dobmin", User.MINIMUM_AGE + "");
@@ -70,10 +64,6 @@ public class Signup extends Form {
         if (r.getParameter("email") != null) {
             email = r.getParameter("email");
         }
-        general = "1".equals(r.getParameter("general"));
-        country = "1".equals(r.getParameter("country"));
-        regional = "1".equals(r.getParameter("regional"));
-        radius = "1".equals(r.getParameter("radius"));
         GigiApiException problems = new GigiApiException();
         try {
             ni.update(r);
@@ -190,15 +180,6 @@ public class Signup extends Form {
 
     private void run(HttpServletRequest req, String password) throws GigiApiException {
         User u = new User(email, password, myDoB.getDate(), Page.getLanguage(req).getLocale(), cs.getCountry(), ni.getNameParts());
-
-        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `alerts` SET `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?")) {
-            ps.setInt(1, u.getId());
-            ps.setBoolean(2, general);
-            ps.setBoolean(3, country);
-            ps.setBoolean(4, regional);
-            ps.setBoolean(5, radius);
-            ps.execute();
-        }
         Notary.writeUserAgreement(u, "ToS", "account creation", "", true, 0);
     }
 
index d241a86..bc602e7 100644 (file)
   <tr>
     <td colspan="3"><font color="red">*</font><?=_Your password is one of many factors to protect your account from unauthorised access. A good password is hard to guess, long, and contains a diverse set of characters. For the current requirements and to learn more, visit our !(/wiki/goodPassword)FAQ!'</a>'.?></td>
   </tr>
-  <tr>
-    <td colspan="3"><?=_It's possible to get notifications of up and coming events and even just general announcements, untick any notifications you don't wish to receive. For country, regional and radius notifications to work you must choose your location once you've verified your account and logged in.?></td>
-  </tr>
 
   <tr>
-    <td valign="top"><?=_Alert me if?>: </td>
-    <td align="left">
-        <input type="checkbox" name="general" value="1"<?=$!general?>><?=_General Announcements?><br>
-        <input type="checkbox" name="country" value="1"<?=$!country?>><?=_Country Announcements?><br>
-        <input type="checkbox" name="regional" value="1"<?=$!regional?>><?=_Regional Announcements?><br>
-        <input type="checkbox" name="radius" value="1"<?=$!radius?>><?=_Within 200km Announcements?></td>
-    <td>&nbsp;</td>
+    <td colspan="3"><input type="checkbox" name="tos_agree" value="1"><?=_I agree to the Terms of Service (!(/policy/ToS)ToS!'</a>').?></td>
   </tr>
 
   <tr>
     <td colspan="3"><?=_When you click on next, we will send a confirmation email to the email address you have entered above.?></td>
   </tr>
-  <tr>
-    <td colspan="3"><input type="checkbox" name="tos_agree" value="1"><?=_I agree to the Terms of Service (!(/policy/ToS)ToS!'</a>').?></td>
-  </tr>
 
   <tr>
     <td colspan="3"><input class="btn btn-primary" type="submit" name="process" value="<?=_Next?>"></td>
index d9de3a9..85e34b9 100644 (file)
@@ -49,14 +49,14 @@ public class RegisterPageTest extends ManagedTest {
 
         String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&mname=mn&suffix=sf&email=";
 
-        String query = defaultSignup + URLEncoder.encode("correct3_" + uniq + "@email.de", "UTF-8") + "&general=1&country=1&regional=1&radius=1&name-type=western";
+        String query = defaultSignup + URLEncoder.encode("correct3_" + uniq + "@email.de", "UTF-8") + "&name-type=western";
         String data = fetchStartErrorMessage(runRegister(query));
         assertNull(data);
         assertSuccessfullRegMail("correct3_" + uniq + "@email.de");
 
         getMailReceiver().setEmailCheckError("400 Greylisted");
         getMailReceiver().setApproveRegex(Pattern.compile("a"));
-        query = defaultSignup + URLEncoder.encode("correct4_" + uniq + "@email.de", "UTF-8") + "&general=1&country=1&regional=1&radius=1";
+        query = defaultSignup + URLEncoder.encode("correct4_" + uniq + "@email.de", "UTF-8");
         data = fetchStartErrorMessage(runRegister(query));
         assertNotNull(data);
 
@@ -170,20 +170,6 @@ public class RegisterPageTest extends ManagedTest {
         assertThat(run, containsString("<option selected=\"selected\">28</option>"));
     }
 
-    @Test
-    public void testCheckboxesStay() throws IOException {
-        String run2 = runRegister("general=1&country=a&regional=1&radius=0");
-        assertThat(run2, containsString("name=\"general\" value=\"1\" checked=\"checked\">"));
-        assertThat(run2, containsString("name=\"country\" value=\"1\">"));
-        assertThat(run2, containsString("name=\"regional\" value=\"1\" checked=\"checked\">"));
-        assertThat(run2, containsString("name=\"radius\" value=\"1\">"));
-        run2 = runRegister("general=0&country=1&radius=1");
-        assertThat(run2, containsString("name=\"general\" value=\"1\">"));
-        assertThat(run2, containsString("name=\"country\" value=\"1\" checked=\"checked\">"));
-        assertThat(run2, containsString("name=\"regional\" value=\"1\">"));
-        assertThat(run2, containsString("name=\"radius\" value=\"1\" checked=\"checked\">"));
-    }
-
     @Test
     public void testDoubleMail() throws IOException {
         long uniq = System.currentTimeMillis();
@@ -221,7 +207,7 @@ public class RegisterPageTest extends ManagedTest {
 
         String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&mname=mn&suffix=sf&email=";
 
-        String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&general=1&country=1&regional=1&radius=1&name-type=western&residenceCountry=DE";
+        String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&name-type=western&residenceCountry=DE";
         String data = fetchStartErrorMessage(runRegister(query));
         assertNull(data);
         User u = User.getByEmail(email);
@@ -236,7 +222,7 @@ public class RegisterPageTest extends ManagedTest {
 
         String defaultSignup = "fname=" + URLEncoder.encode("ab", "UTF-8") + "&lname=" + URLEncoder.encode("b", "UTF-8") + "&pword1=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&pword2=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") + "&day=1&month=1&year=1910&tos_agree=1&mname=mn&suffix=sf&email=";
 
-        String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&general=1&country=1&regional=1&radius=1&name-type=western&residenceCountry=invalid";
+        String query = defaultSignup + URLEncoder.encode(email, "UTF-8") + "&name-type=western&residenceCountry=invalid";
         String data = fetchStartErrorMessage(runRegister(query));
         assertNull(data);
         User u = User.getByEmail(email);